Javascript text box and check box help

liunx

Guest
I am trying to figure out some code that will uncheck a check box in a form if text is entered in a text box.<br />
<br />
I also need to do the opposite...delete text in a text box when a checkbox is clicked.<br />
<br />
It should be easy, but the "Onchange()" function doesn't appear to be very responsive.<!--content-->Try this:<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br />
<br />
<html><br />
<head><br />
<title>Untitled</title><br />
<script language="JavaScript" type="text/javascript"><br />
<!--<br />
function clrTxt(){<br />
document.forms.form1.txtBox.value="";<br />
}<br />
<br />
function uncheck(){<br />
document.forms.form1.chbox.checked=0;<br />
}<br />
//--><br />
</script><br />
<br />
</head><br />
<body><br />
<form name="form1" ><br />
<input name="chbox"type="checkbox" checked="checked" onclick="clrTxt()" /><br />
&nbsp;&nbsp;<br />
<input name="txtBox" type="text" onchange="uncheck()" /><br />
</form<br />
</body><br />
</html><!--content-->Originally posted by rwhitten <br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<br />
"http://www.w3.org/TR/html4/loose.dtd"><br />
<html><br />
<head><br />
<title>Untitled</title><br />
</head><br />
<body><br />
<form name="form1" ><br />
<input name="chbox" type="checkbox" checked onclick="elements[1].value=''" /> Clear<br />
&nbsp;&nbsp;<br />
<input name="txtBox" type="text" onchange="elements[0].checked=this.value.length" /><br />
</form><br />
</body><br />
</html><!--content-->
 
Back
Top