I'm a programming noob. I have a selectmenu where I have two buttons that allow the user to add and remove options in the menu. I would like to assign each option in the selectmenu to a variable of type object, but unfortunately I don't know how many options the user will add to the selectmenu up front. Is there a way to dynamically declare a new global variable each time as the user adds a new option to the selectmenu?
Please see html code for selectmenu below.
<select id="List">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</select>
Please see jquery code below to add an option to the selectmenu.
$(".bt1").click(function () {
var opt = $("#ip1").val();
$('#List')
.append($("<option></option>")
.attr("value", opt)
.text(opt));