PDA

View Full Version : Need Help to make Forms field Invisble using "onchange"


pktyagi
05-21-2003, 10:06 PM
Hi,

I have a big form with a many input fields. The very first field is
is a list type (Select) which is having 2 values YES and NO. Its a kind of drop down list field. Now based on the selection of value or change of selection in this field I need to make visible/hidden rest of the field/form-part. I mean as soon as I choose/select the value in this list field it will make all the fields or rest of the forms visible/hidden. For example If I select YES, it will show some fields to inputs and I will be able to enter values in those fields. If I select NO it will not show those fields/forms at all.
Please suggest on this. Any help is appreciated.

Thanks.

chrismiceli
05-21-2003, 11:00 PM
simple enough


<script type="text/javascript">
function check() {
if(document.sel.options[document.sel.options.selectedIndex].value==1) {
for(x=0;x<document.form0.elements.length;x++) {
document.form0.elemens[x].type="hidden";
}
}
if(document.sel.options[document.sel.options.selectedIndex].value==0) {
for(x=0;x<document.form0.elements.length;x++) {
document.form0.elemens[x].type="input";
}
}
}
</script>
<select name="sel">
<option value="1">yes</option>
<option value="0">no</option>
</select>
<form name="form0">
<input type="text">
</form>


that is if your form is just inputs.