Multiple ` it should not be visible in the second or third` – Adrian Enriquez Mar 09 '15 at 12:52

  • Oh so you want to select each option only once..right? – planet260 Mar 09 '15 at 12:52
  • @planet260 yes that's right. – Adrian Enriquez Mar 09 '15 at 12:53
  • 1 Answers1

    1

    So every time you are creating a new drop down you are inserting static values. By analyzing the code I see the selected value always have a class item. So what we can do is create a new array to show in dropdown and filter out the ones already selected. And then we can bind it in drop down.

    To filter out you can use filter

    saveAsOptionsFiltered = saveAsOptions; //Initialize with your all drop down options
    $(".item").each(function(index,element) {
        /*Filter out the already selected ones*/
        saveAsOptionsFiltered = saveAsOptionsFiltered.filter(function (savevalue) {return savevalue.text !== $(element).text() }); 
    });
    

    JSFiddle

    I have not handled the condition when all are selected and you stop adding more I have just shared the code in which you can filter out the selected ones.

    planet260
    • 1,384
    • 1
    • 14
    • 30