Page 1 of 1

Quick JS question

Posted: 2004-01-15 11:27am
by haas mark

Code: Select all

<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--

function jumpPage(newLoc) {
	newPage = newLoc.options[newLoc.selectedIndex].value
	
	if (newPage != "") {
		window.location = newPage
	}
}

//-->
</script>
</head>

<body onLoad="document.myForm.newLocation.selectedIndex=0">

<div align="center"><form action="" name="myForm"><select name="newLocation" onChange="jumpPage(this.form.newLocation)">
      <option value="" selected>Select a State</option>
      <option value="cmal.htm">Alabama</option>
      <option value="cmak.htm">Alaska</option>

// .....

      <option value="cmwy.htm">Wyoming</option>
    </select>
</form></div>
</body>
</html>
Ok then. So given code like this (which works perfectly) how do I make it so that a selected option opens up in a new window?

~ver

Posted: 2004-01-15 08:56pm
by The Third Man
I think you want to be playing with window.open()

Try replacing the line:
window.location = newPage
with
window.open(newPage)

Check your references for the full syntax of open()

Posted: 2004-01-15 09:32pm
by haas mark
Thanks. :)

~ver