wysiwygGER01
Programmer
Hi,
I think I got a very basic question but can't work it out.
I have a drop down box. By selecting a value from the drop down list I'd like to hide one part of my form and show another part.
The code for collapsing and expanding my form works great when using static values but I can't get it to work together with the value I'm selecting from the drop down list.
<SCRIPT type=text/javascript>
<!--
function collapseElem(obj)
{
var el = document.getElementById(obj);
el.style.display = 'none';
}
function expandElem(obj)
{
var el = document.getElementById(obj);
el.style.display = '';
}
//-->
</SCRIPT>
<ul class=mainForm id="mainForm_2">
<li class="mainForm" id="fieldBox_6">
<select class=mainForm name=field_6 id=field_6 onchange="collapseElem('mainForm_2'); expandElem(mainForm_2.field_6.options[mainForm_2.field_6.selectedIndex].value);">
<option selected></option>
<option value="mainForm_3">Management</option>
<option value="mainForm_4">Engineering</option>
<option value="mainForm_5">Operations </option>
</select>
</li>
</ul>
If I change the onchange attribute to the below it will work.
onchange="collapseElem('mainForm_2');expandElem('mainForm_3');"
I think I got a very basic question but can't work it out.
I have a drop down box. By selecting a value from the drop down list I'd like to hide one part of my form and show another part.
The code for collapsing and expanding my form works great when using static values but I can't get it to work together with the value I'm selecting from the drop down list.
<SCRIPT type=text/javascript>
<!--
function collapseElem(obj)
{
var el = document.getElementById(obj);
el.style.display = 'none';
}
function expandElem(obj)
{
var el = document.getElementById(obj);
el.style.display = '';
}
//-->
</SCRIPT>
<ul class=mainForm id="mainForm_2">
<li class="mainForm" id="fieldBox_6">
<select class=mainForm name=field_6 id=field_6 onchange="collapseElem('mainForm_2'); expandElem(mainForm_2.field_6.options[mainForm_2.field_6.selectedIndex].value);">
<option selected></option>
<option value="mainForm_3">Management</option>
<option value="mainForm_4">Engineering</option>
<option value="mainForm_5">Operations </option>
</select>
</li>
</ul>
If I change the onchange attribute to the below it will work.
onchange="collapseElem('mainForm_2');expandElem('mainForm_3');"