Set a dropdown value to selected based on another dropdown selection
sorry if this is a repeat, but I didn't see anything like it, it's a bit complex to search for.
Here's my problem:
I have a select box that can contain multiple rows, with each row containing a client ID, dates, and a service code that they're billing for.
I have the values for all of these pulling and splitting just fine, and the ones that populate text boxes work great, but the billing code is chosen from another select box and I need to update the selected option to be the one returned from the main selection.
i.e. the screen loads with blank fields and the first option showing in the billing code selection box. The user then selects an old record to update from the main display and all of the blank text boxes are filled, how do I make the right code be selected in the billing code drop-down?
I can include code here for anything if people want to see it, but everything I have works, it's just updating this second drop-down when the first is changed.
And I don't want to add-remove values, they're already set by a SQL database call to the valid values.
Thanks so much for any help!
Found a solution, of sorts.
I don't love this, it's not elegant, but it gets it done and keeps me on schedule.
In case this helps anyone else:
I seems like there should be some way to return the index of a specific value then just set the selectedIndex. If anyone know that syntax, please let me know.
var lobj_SelectBox = document.getElementById("sel_Rate");
var ls_SelBoxCode = "";
var i = 0;
lobj_SelectBox.selectedIndex = i;
ls_SelBoxCode = (lobj_SelectBox.value).substring(0,5);
}while ( ( i < lobj_SelectBox.length ) && ( ls_SelBoxCode != ls_Code ) )