I have HTML5 code:
Select item:
And code behind:
function fillItemsList(jsonResponse){
var data = jsonResponse.invocationResult;
var itemsString = data.commodities.toString();
itemsList = itemsString.split(",");
$('#selectItem').empty();
var options = "";
for (var i = 0; i < itemsList.length; i++) {
WL.Logger.debug(itemsList[i]);
options += '<option value= "' + itemsList[i] + '">' + itemsList[i] + '</option>';
}
$('#selectItem').html(options);
busyIndicator.hide();
//$('#selectItem').Attributes.Add("onChange", "return itemSelectionChange();");
}
function itemSelectionChange(){
WL.Logger.debug("Selected item changed");
var index = $('#itemsList').prop("selectedIndex");
var selectedItem = itemsList[index];
getDeals(selectedItem);
}
I am using IBM Worklight to create a web app and using this code. The select dropdown gets all the values but the function doesnt get invoked when the selection is changed.
depends on what version of jQuery you are using, but the line:
should be something like: