I am using so javascript to load different forms based on a drop down selection like below:

```
<select id = "opts" onchange = "showForm()">
<option value = "0">Select Option</option>
<option value = "1">Option 1</option>
<option value = "2">Option 2</option>
</select>

<div id = "f1" style="display:none">
<form name= "form1">
Content of Form 1
</form>
</div>

<div id = "f2" style="display:none">
<form name= "form2">
Content of Form 2
</form>
</div>

<script type = "text/javascript">
function showForm(){
var selopt = document.getElementById("opts").value;
if (selopt == 1) {
document.getElementById("f1").style.display="block";
document.getElementById("f2").style.display="none";
}
if (selopt == 2) {
document.getElementById("f2").style.display="block";
document.getElementById("f1").style.display="none";
}
}

</script>

```

I have removed the actually form details because they dont matter at this point. Anyways, when the form is submitted it passes a series of validations:

```
if (isset($_POST['submitted'])) { 
 //validation codes

}

```

This works great, but if the validation fails it reloads the page and therefore resets the dropdown box, and doesn't show the previously selected option. I want it to keep the previous selection, or just to have for example load selection 1 into the javascript bit when the submission fails. any ideas?

Ian