How do I create an array of values from a drop down list?
+2
A:
The following should do it. It will create an array from all the values of your select:
var data = $("#theSelect options").map(function() {
return this.value;
}).get();
$('#txtEntry').autocomplete(data);
karim79
2010-03-03 16:01:17
sorry--that's a no-go. I do get a VS message saying, 'get' is a new reserved word and should not be used as an identifier. Not sure if that's to blame or not.
Matt
2010-03-03 16:26:24
+1 for mentioning .map()
takpar
2010-03-03 18:35:01
A:
This works instead:
var data[]; $('#ddlCodes option').map(function(i, option) { data[i] = $(option).val(); });
Matt
2010-03-04 14:54:49