Hi All,
I have a select box that gets cloned. I want to remove the user's previous selection from each cloned select box. Here is the method that does the clone() :
function addselect(s){
$('#product_categories > .category_block:last').after(
$('#product_categories > .category_block:last').clone()
); set_add_delete_links(); return false;
}
function set_add_delete_links(){ $('.remove_cat').show(); $('.add_cat').hide(); $('.add_cat:last').show(); $("#product_categories > .category_block:only-child > .remove_cat").hide(); }
function removeselect(s){ $(s).parent().remove(); set_add_delete_links(); return false; }
This kinda works but doesn't remove the last selected:
$('#product_categories > .category_block:last option:selected').remove();
Here is the HTML
<div id="product_categories">
<div class="category_block">
<select name="category_ids[]" id="cat_list">
<option value="">Select Attribute</option>
<option value="1770">Foo0</option>
<option value="1773">Foo1</option>
<option value="1775">Foo2</option>
<option value="1765">Foo3</option>
<option value="1802">Foo4</option>
<option value="1766">Foo5</option>
</select>
<input class="specsinput" type="text" name="specs[]" value="" />
<a href="#" onClick="return removeselect(this);" class="remove_cat"> [-] </a>
<a href="#" onClick="return addselect(this);" class="add_cat"> [+] </a>
</div>