/    Sign up×
Community /Pin to ProfileBookmark

dynamic display of text element

Hi

I am trying to display text elemet dynamically based on check box is checked or not.

Following script works fine in IE 6 but not in Netscape 4.7, is there any alternative to fix the problem.

<html>
<head>
<title>Checkbox Demo</title>
<script language=”javascript” type=”text/javascript”>
function shownone(frm) {
if (frm.mycheckbox.checked == true) {
document.forms[0].elements[1].style.display = “block”;
}
else {
document.forms[0].elements[1].style.display = “none”;
}
}
</script>
<script language=”javascript” type=”text/javascript”>
function xyz()
{
if ( ! document.forms[0].elements[0].checked)

{

document.forms[0].elements[1].style.display = “none”;

}

}

</script>
</head>
<body onLoad=”xyz()”>
<form name=”myform”>
<table>
<tr><td>
<input name=”mycheckbox” tabindex=”1″ type=”checkbox” value=”shown” onClick=”shownone(this.form)” onFocus=”shownone(this.form)”>
</td></tr>
<tr><td>
<input id=”mytext” tabindex=”2″ name=”mytext” type=”text” onBlur=”shownone(this.form)”>
</td></tr>
<tr><td>
<input id=”mytexttwo” tabindex=”3″ name=”mytexttwo” value=”this is text two” type=”text”>
</td></tr>
</table>
</form>
</body>
</html>

Regards

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @rock123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...