Jump to content

Recommended Posts

Posted

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


Posted

What you could do, is have the checkbox visible at all times, but only able to use when option one has been picked by using a javascript code, such as this:

function updatefields(){
if (document.getElementById("selectedProd").options[document.getElementById("selectedProd").selectedIndex].value=='code1')
{
document.getElementById("checkbox").disabled=false;}
else{
document.getElementById("checkbox").disabled=true;
}
}

<input type="checkbox" name="checkbox" id="checkbox"/>

Hoped that helped.

  • 2 weeks later...
Posted

You could also make the checkbox initially hidden :

<input id="checkboxNamedID" type="checkbox" style="display: none;">

Then in your javascript show it with :

document.getElementById('checkboxNamedID').style.display = '';

And hide it again with :

document.getElementById('checkboxNamedID').style.display = 'none';

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...