How do I remove items from, or add items to, a select box? I'm running jQuery, should that make the task easier. Below is an example select box.
<select name="selectBox" id="selectBox">
<option value="option1">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
<option value="option4">option4</option>
</select>
You can delete the selected item with this:
This is useful if you have a list and not a dropdown.
To add the item I would create second select box and:
Not jQuery though.
I had to remove the first option from a select, with no ID, only a class, so I used this code successfully:
To Remove an Item
To Add an item
To Check for an option
To remove a selected option
The following links will be helpful-
http://api.jquery.com/remove/
http://api.jquery.com/append/
Just to augment this for anyone looking, you are also able to just:
and