Q:

Auto populate 2 dropdowns (fed with AJAX) in a row, with value in session. First one triggering the second

Good day to you all,
I have two dropdowns on a form, where the values in the second are populated from the selection made in the first one. For retaining the value on form reload, the values in the first dropdown are populated on load, but the onchange event does not get triggered (it works when I manually select the value from the first dropdown), hence the second dropdown is not auto populated.
The values to be selected in both dropdowns are present in the session. 
Summary - 

Populate 1st drop down, on reoad -> done 
select its previous value stored in session -> done
load the values in the second dropdown, based on the 1st selection ->
pending  :(
select the value of the second drop down in session -> pending  :(

I am kinda stuck, can someone suggest something? By the way, I am using PHP and jQuery.
Basically, on an accidental page reload, the drop downs must get populated like dominos falling on each other, tish tish tish,, the values for each of them are available in session,(saved before the reload)

A:

You can manually trigger the change event on the first select when it's already populated:
// trigger onchange on the first select in the page
document.getElementsByTagName("select")[0].onchange();

// trigger onchange on #theselect
document.getElementById("theselect").onchange();

