I\'d like to build s on the fly in a box based on an AJAX response; i.e. if the responseText is 3, I\'d like to build 3 options:
You can do:
var routeSelect = $("#PAG_POSITION").get(0);
routeSelect.html(''); //clear-out options
if (isNaN(opts) || opts == 0) {
//Handles case where your response is invalid or zero
routeSelect.append($('<option/>').val(0).html(0));
} else {
//Add n items to the dropdown
for(var i = 0; i < opts; ++i) {
routeSelect.append($('<option/>').val(i).html(i));
}
}
Hope this helps.