Hi how do I use jQuery to show a Jquery mutliselect based on a checkbox option, here is my codes


 <input type="checkbox" value= "checkbox1" name="checkbox1">
 <select id="dropdown" name="dropdown" multiple="multiple">
<option id="item"></option>



Recommended Answers

All 2 Replies

I neither test your code nor guessing what you want to do with the page...

But I think if you want to add event handler for #checkbox, you have to add attribute id="checkbox" in <input> tag

One more thing, perhaps you forgot to add } to the end of script

You need to use $('input#checkbox1').click() and apply a function to that.

I've done a mini mockup on jsFiddle, but for reference here is the code explained:

// When checkbox clicked
$('input#checkbox1').click( function(){

    // If has been checked or unckecked
    if ($('input#checkbox1').is(':checked')) {

        // Smoothly animate the div in
        $( ".select" ).slideDown( "slow" );
    } else {

        // Smoothly animate the div away
        $( ".select" ).slideUp( "slow" );
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.