javascript - Filter duplicate options from select using Jquery -
question: got 2 option name try , restrock , when @ try option add macbook pro assigned box , after that, go restock option add same product call macbook pro, system allow user add again. that, how can check when try option aldready got macbook pro when user try add again in restock option system auto remove mac book pro try option , add new macbook pro restock option???
code write
function addselectedproducts(row_lab) { $('#product_placeholder'+row_lab+' :selected').each(function() { $(this).remove(); $('#related'+row_lab+' option[value=\'' + $(this).attr('value') + '\']').remove(); $('#related'+row_lab).append('<option value="' + $(this).attr('value') + '">' + $(this).text() + '</option>'); $('#product_added input[value=\'' + $(this).attr('value') + '\']').remove(); var featured_string = document.getelementbyid('imploding_feature'+row_lab).value; var sear_exist = featured_string.search('/'+$(this).attr('value')+'/'); if(sear_exist == -1){ featured_string = featured_string + $(this).attr('value') + ','; featured_string = featured_string.replace(/^,/, ''); $('#imploding_feature'+row_lab).val(featured_string); } }); }
Comments
Post a Comment