re-populate combobox
Hi all,
I've a code in wich I do fill 2 comboboxes.
By selecting a value in the first one, the options change in the second one.
Now when I click on "back" button of IE, the values are lost. I mean I've
the value in the first combo, but the second one is empty.
I do save the values in a session variable (my site is in PHP), so I know
wich values have been selected. So my question is:
how to select the values again ?
In the example below, when you submit, the values are passed by GET (seen on
URL). Clicking "back" button, the selected value in combo1 is selected
again, but the combo2 is empty.
I've to select a new value and select the desired value again to get it
filled.
Here is the code (filename testjs.html):
<html>
<body>
<form name="FormSubmit" action="testjs.html">
<select NAME="SELECT1" ID="SELECT1"
onChange="subselect(this.options.selectedIndex)" ="combobox">
<option value="" selected>all</option>
<OPTION VALUE="1">option1</OPTION>
<OPTION VALUE="2">option2</OPTION>
</select>
<select NAME="SELECT2" ID="SELECT2" class="combobox">
<option value="" selected>all</option>
</select>
<input type="submit" name="submit">
<script>
<!--
var groups=document.FormSubmit.SELECT1.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
group[0][1]=new Option("option1")
group[0][2]=new Option("option2")
group[1][0]=new Option("all ")
group[1][1]=new Option("sub1-1","1")
group[1][2]=new Option("sub1-2","2")
group[2][0]=new Option("- all - ")
group[2][1]=new Option("sub2-1","3")
group[2][2]=new Option("sub2-2","4")
var temp=document.FormSubmit.SELECT2
function subselect(x){
for (i=temp.options.length-1;i>0;i--)
temp.options[i]=null
for (k=0;k<group[x].length;k++){
temp.options[k]=new Option(group[x][k].text,group[x][k].value)
}
temp.options[0].selected=true
}
//-->
</script>
</form>
</body>
</html>
Thanks for helping.
Bob |