Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form 10.1 | Q933 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.