Jump to content

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


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...