PDA

View Full Version : Populating Textbox when checkbox checked


OFAH
12-04-2002, 03:28 PM
I am definitely no JavaScript expert by any means, so if this is an easy task, please don't laugh :(

What I want/need to do is populate a textbox with a value (say "N/A") when the user checks off a particular checkbox.

What would be the simplest way to do this?

Any help would be greatly appreciated.

beetle
12-04-2002, 04:34 PM
Here's one way...<script type="text/javascript">

function whatever(cBox) {
if (cBox.checked)
cbox.form.myText.value = "N/A";
}

</script>

<form>
<input type="text" name="myText" />
<input type="checkbox" name="myCheck" onclick="whatever(this);" />
</form>

OFAH
12-04-2002, 05:12 PM
Thank you very much for the quick reply. The code you submitted above worked great.

I really appreciate it :)