Jump to content

Recommended Posts

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

lonewolf, and then use ajax to built the checkbox or use simple js to change the style.display of the element? Either would work, but this isn't the board for JS.

Kabucek, this seems to be a good time to use js, but if you want to go pure html and php, here is what you can do.

They will need to select from the drop down then submit the form. interchange $_GET for $_POST if you are using form method = post

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

<option  value='code2' <?php if($_GET['selectedProd'] == "code2"){ echo "selected"; } ?>>event 2, IL</option>
</select>
<?php
if($_GET['selectedProd'] == 'code1'){
echo "Box here <input type='checkbox' name='check' value='1'>";
}
?>

you'll probably need to make several adjustments, but essentially that is what you could do.



<select name"selectedProd" onChange="if (this.selectedIndex == 1){ document.getElementById('chkBoxDisp').innerHTML = '<input type=checkbox>'; }else{ document.getElementById('chkBoxDisp').innerHTML = ''; }" >

 <option value="">...</option>

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

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

</select>

<div id="chkBoxDisp" style="width: 100%; height: 15px; background-color: #ffffff;"><!-- CHECKBOX --></div>

 

 

That should do it:P

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.