create checkbox when choice is made from dropdown

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

create checkbox when choice is made from dropdown

Post 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
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: create checkbox when choice is made from dropdown

Post 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>
Post Reply