Click to See Complete Forum and Search --> : Textarea filled by a checkbox


hismightiness
02-07-2003, 01:58 PM
I have a need to fill in a textarea with a specified value only if a checkbox is checked. If it is not checked, then nothing will happen. I have been trying to write it myself and with little result. Here is what I have so far:

<script language="javascript">
<!--
function checkCheckBox(f){
if (document.formname.s2q1test.value == true ){
var obj_text = document.FrontPage_Form1.s2q1comments
obj_text.value = "n/a"
}
}
-->
</script>

AND THE HTML...

<tr><td>
<input type="checkbox" name="s2q1test" id="s2q1test" value="0" tabindex="1" onclick="checkCheckBox(this)">Does not apply to my job
</td><td>
<textarea rows="4" name="s2q1comments" id="s2q1comments" cols="40" tabindex="2"></textarea>
</td></tr>

Any help would be appreciated...

BestZest
02-07-2003, 02:03 PM
Use:
if (document.formname.s2q1test.checked == true )

Hope this works

BestZest

hismightiness
02-07-2003, 02:07 PM
I hate it when I miss the little things!!! I have been working on this for the better part of the day and could not for the life of me figure out what was wrong.

Thank you so much for that slap back into reality. The code isn't blurring in front of my eyes anymore... Have a wonderful day!!!