I am dynamically setting the values for a select box using java script
var dropDwnObj = document.getElementById("workingBranchCodeId");
dropDwnObj.options.length = 0;
var anOption = document.createElement("OPTION");
dropDwnObj.options.add(anOption) ;
for(var i = 0; i < jsonResult.subLocationList.length; i++) {
var anOption = document.createElement("OPTION");
dropDwnObj.options.add(anOption) ;
if(selValue == jsonResult.subLocationList[i].displayKey) {
anOption.innerHTML = jsonResult.subLocationList[i].displayValue;
anOption.value = jsonResult.subLocationList[i].displayKey;
}
}
How can I make this value as the selected value for the select box? currently it is coming like an option but i want this option to be the selected one for the select box