Here is my javascript:
$('#Service').val("2");
$("#Service").change(); // Sets new options in subservice.
$('#Subservice').val("5");
//EDIT:
alert($('#Subservice').length); // Returns 1, when there are far more in it.
Service and Subservice are drop down boxes.
On Service change, the new list of subservices is populated.
This is setting the fields of the record to be editted. It executes when I click an Edit Button.
It sets the service dropdownbox, then is populating the subservice dropdown box, then attempting to set the correct dropdown selection for it.
However it is not correctly setting the subservice box. The options are correct, so .change() is working and service sets correctly. However Subservice is not being set. And there is an entry with value 5 in it.
My only reasoning is that .change is firing, but carrying on to setting .val before it finishes. And so no options exist at the time of setting. However I dont see why it would be threading either. So Im not sure what is going on or how to fix it.
change last line in your code as