Hello
I have minor issue with dropdown box that is triggered by a JS function. I have two dropdown box, 1. Select State, 2. Select Entity
When you select "Outside of US" from "Select State" dropdown, the js pushes content down and enables another dropdown with list of countries. When you select "Other" from Select Entity, the js should push content down and enables a textarea.
At this point, my first scenerios works fine for selecting countries, but when I select "Other" it open the list of countries dropdown instead of the textarea. How will I fix this.
Here is the code that I am using.
JS Code:
<script type="text/javascript">
<!--
//this function shows/hides the moreFields div containing additional form elements
function showhide(obj){
//here we get the value of the select object
var curSel=obj.options[obj.selectedIndex].value
//if A, B, or no option selected, hide moreFields div
if(curSel=='Other'){
document.getElementById('specifyother').style.display="block";
}else if(curSel=='Outside the US' | curSel=='' ){
document.getElementById('selectcountry').style.display="block";
}else{
//otherwise show moreFields div
document.getElementById('selectcountry').style.display="none";
document.getElementById('specifyother').style.display="none";
}
}
//-->
</script>
HTML Code:
<select name="dropdown" id="dropdown" onchange="showhide(this)"><option value="selectstate">Select State</option><option value="">Outside the US</option></select>
<select name="dropdown" id="dropdown" onchange="showhide(this)"><option value="selectentity">Select Entity</option><option value="">Other</option></select>
<div id="selectcountry" style="display:none;"><select name="country" id="country"><option value="">Select</option>
<option value="United States">United States</option>
<option value="United Kingdom">United Kingdom</option></select></div>
<div id="specifyother" style="display:none;"><div><label>If "Other" please specify </label><input type="text" maxlength="128" name="submitted[other]" id="" size="60" value="" class="form-text required" /></div></div>
I got some help from a previous post here.
[
webmasterworld.com...]
I would really appreciate any advice.