Sample binding for the drop down box select
- 2020-03-30 03:51:08
- OfStack
Bind text to the text
var locationCity = productViewObj.Product.LocationCity;
var countCity = $("#slCity option").length;
for (var i = 0; i < countCity; i++) {
if ($("#slCity").get(0).options[i].text == locationCity) {
$("#slCity").get(0).options[i].selected = true;
break;
}
}
Bind value by value
var deliveryTemplateID = productViewObj.Product.DeliveryTemplateID;
var deliveryCount = $("#deliverySelect option").length;
for (var i = 0; i < deliveryCount; i++) {
if ($("#deliverySelect").get(0).options[i].value == deliveryTemplateID) {
$("#deliverySelect").get(0).options[i].selected = true;
break;
}
}