0

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

//html

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

//jQuery

$("#checkbox").change(function(){
     $('#dropdown').multipleSelect();    

Edited by pritaeas: Moved to Javascript.

3
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by mattster
0

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

Edited by Tu Dinh

0

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" );
    }
});
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.