You are here: irt.org | FAQ | JavaScript | Form | Q1670 [ previous next ]
Try:
<html>
<head>
<script lannguage="JavaScript"><!--
function fillIt(type,theForm) {
if (type == 1) {
theForm.elements['fieldA'].value = 'Now is';
theForm.elements['fieldB'].value = 'the time';
theForm.elements['fieldC'].value = 'for all';
theForm.elements['fieldD'].value = 'good men';
}
else if (type == 2) {
theForm.fieldA.value = 'to come';
theForm.fieldB.value = 'to the';
theForm.fieldC.value = 'aid of';
theForm.fieldD.value = 'their country';
}
}
//--></script>
</head>
<body>
<form>
<br><input name="fieldA" type="text" value="initial value">
<br><input name="fieldB" type="text" value="initial value">
<br><input name="fieldC" type="text" value="initial value">
<br><input name="fieldD" type="text" value="initial value">
<br>Part1:
<input type="checkbox" onClick="if (this.checked) fillIt(1,this.form)">
<b>Part2:
<input type="checkbox" onClick="if (this.checked) fillIt(2,this.form)">
</form>
</body>
</html>