Jump to content

create checkbox when selection is made from dropdown

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?


Link to comment
Share on other sites

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')

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

Hoped that helped.

Link to comment
Share on other sites

  • 2 weeks later...

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';

Link to comment
Share on other sites

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...