Following is the script that makes a jump menu.Using javascript i have set the index of the options
tag to be equal to 0.The scrip works fine except one.After i jump to another page from the jump menu the index is not reset to the index 0.Instead it is set to the index where i had clicked.Why is it so ? What is the problem with script ?
script:
window.onload = startInit;
function startInit() {
document.getElementById("newLocation").selectedIndex = 0;
document.getElementById("newLocation").onchange = jumpPage;
}
function jumpPage() {
var newLoc = document.getElementById("newLocation");
var newPage = newLoc.options[newLoc.selectedIndex].value;
if(newPage != "")
window.location = newPage;
}
HTML
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="script.js">
</script>
</head>
<body bgcolor="#FFFFCC">
<center>
<form>
<select id="newLocation">
<option value="myworld.gif">first</option>
<option value="myhome.gif">second</option>
<option value="myroom.gif">third</option>
<option value="mybed.jpg">fourth</option>
</select>
</form>