I am trying to populate a dropdown select with an array using jQuery.
Here is my code:
// Add the list of numbers to the drop down here
The solution I used was to create a javascript function that uses jquery:
This will populate a dropdown object on the HTML page. Please let me know where this can be optimized - but works fine as is.
function util_PopulateDropDownListAndSelect(sourceListObject, sourceListTextFieldName, targetDropDownName, valueToSelect)
{
var options = '';
// Create the list of HTML Options
for (i = 0; i < sourceListObject.List.length; i++)
{
options += "\r\n";
}
// Assign the options to the HTML Select container
$('select#' + targetDropDownName)[0].innerHTML = options;
// Set the option to be Selected
$('#' + targetDropDownName).val(valueToSelect);
// Refresh the HTML Select so it displays the Selected option
$('#' + targetDropDownName).selectmenu('refresh')
}