I have a javascript function that populates a form using the option value of a select. When the option is selected, it populates the fields and the other select ('selVehicleEditModel'), but doesn't select an option.
function displayEditVehicle() {
var data = jQuery('#selVehicleEditList option:selected').val();
var dataArray = data.split("|");
jQuery('#inpVehicleId').val(dataArray[0]);
jQuery('#selVehicleEditMake option[value="' + dataArray[4] + '"]').attr("selected", "selected");
jQuery('#inpVehicleEditVehicleId').val(dataArray[9]);
jQuery('#inpVehicleEditColor').val(dataArray[7]);
jQuery('#inpVehicleEditLicense').val(dataArray[8]);
jQuery('#inpVehicleEditYear').val(dataArray[6]);
//get all models for make from database
updateVehicleEditModel();
jQuery('#selVehicleEditModel option[value="' + dataArray[5] + '"]').attr("selected", "selected");
}
At first, I thought maybe there was a problem with the model (dataArray[5]) being blank or null or something else unexpected, so I put an alert in:
updateVehicleEditModel();
alert(dataArray[5]);
jQuery('#selVehicleEditModel option[value="' + dataArray[5] + '"]').attr("selected", "selected");
that confirmed that value was correct ("EXPLORER" in dataArray[5], "EXPLORER" in option value), but it also selected the proper option. Took the alert out, and it's back to not selecting any option.
Any ideas on what is going on here?