Page 1 of 1

create checkbox when choice is made from dropdown

Posted: Mon Mar 30, 2009 4:31 pm
by kabucek
hello @LL,

I have some dropdown

<select name='selectedProd'>



<option value='code1'>event 1,IL</option>

<option value='code2'>event 2, IL</option>


I want to create checkbox visible only if user picks event 1 from dropdown, but checkbox would not show up if event 2 will be selected.
is that possible?

thanks

Re: create checkbox when choice is made from dropdown

Posted: Wed Apr 01, 2009 12:27 am
by novice4eva
yes, very possible.

Code: Select all

 
<select name='selectedProd' id='selectedProd'  onchange="showHide()">
<option value='code1'>event 1,IL</option>
<option value='code2'>event 2, IL</option>
</select>
<script>
function showHide()
{
if(document.getElementById('selectedProd').value=='code1')
    document.getElementById('THE ID OF DIV THAT CONTAINS THE CHECKBOX OR THE CHECKBOX ITSELF')).style.display='inline';//OR BLOCK
}
else
document.getElementById('THE ID OF DIV THAT CONTAINS THE CHECKBOX OR THE CHECKBOX ITSELF')).style.display='none';
</script>