Jump to content

multiple selection change : chcek if that option is in the <ul> - if not append it there


roberto68

Recommended Posts

I've 4 dropdowns (multiple select) - when value of any changes = user selects -> append that option to <ul>, if deselect => remove that option from <ul>

that dropdowns are in 1 form so right now I've smth like this - I know it is not all OK

    $(".submit").attr('disabled','disabled'); //         $("#dropdowns").change(function() {           if($(this).val()===""){           $(".submit").removeAttr('disabled');                        } else {        $(".submit").attr('disabled','disabled');                                }for (i=1; i<4; i++) {           $('#"dd"+i option').each(function() { //check if smth is selected in each dd    if($(this).is(':selected')   { var sel =   $(this).(':selected').val();     if( $('ul').has("li").val() == sel){  // if there is an li with that value                                   }                else{                $('<li>').text(sel).prependTo('.categories');  // <ul> called categories                  }                                   }                                                 });                           }                           });
Edited by roberto68
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
×
×
  • Create New...