I have two different dropdownmenus and with the following code, I am able to change the content of menu B upon which entry the user selected in menu A. For an example, menu A contains the entries "1" and "2", now menu B will either contain "X" and "Y" (user selected "1") or "3" and "4" (user selected "2").

Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
team = new Array(
new Array(
new Array("x", "xvalue"),
new Array("y", "yvalue")
),
new Array(
new Array("3", "3value"),
new Array("4", "4value")
)
);

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;

for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null; 
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}

if (itemArray != null) {
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1]; 
}
j++;
}

selectCtrl.options[0].selected = true;
   }
}
//  End -->
</script>
 
 
<form name="main">
<select name="menua" onChange="fillSelectFromArray(this.form.menub, ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));">
<option value="0">Please Choose ...</option>
<option value="1">1</option>
<option value="2">2</option>
</select>

<select name="menub">
<option value="0">Please Choose ...</option>
</select>
</form>


My problem is the following:
I am filling both menus with data from the database and I would like to be able to preselect an entry in both menus (specifically the entry which the user has supplied before).

Does someone know of a way to do this? Doesn't have to necessarily depend on the previous code, it can be anything. I would just like to do it client-side without having to reload the page.