Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q933 How can I set the value of a form field when a check box is selected?

You are here: irt.org | FAQ | JavaScript | Form | 10.1 | Q933 [ previous next ]

Try:

<script language="JavaScript"><!--
function setField(what) {
    if (what.myTick.checked)
        what.myText.value = 'checked';
    else
        what.myText.value = '';
}
//--></script>

<form>
<input type="checkbox" name="myTick" onClick="setField(this.form)">
<input type="text" name="myText">
</form>

Feedback on 'Q933 How can I set the value of a form field when a check box is selected?'

©2018 Martin Webb