Quick JS question

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

Post Reply
User avatar
haas mark
Official SD.Net Insomniac
Posts: 16533
Joined: 2002-09-11 04:29pm
Location: Wouldn't you like to know?
Contact:

Quick JS question

Post 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
Robert-Conway.com | lunar sun | TotalEnigma.net

Hot Pants à la Zaia | BotM Lord Monkey Mod OOK!
SDNC | WG | GDC | ACPATHNTDWATGODW | GALE | ISARMA | CotK: [mew]

Formerly verilon

R.I.P. Eddie Guerrero, 09 October 1967 - 13 November 2005


Image
User avatar
The Third Man
Jedi Knight
Posts: 725
Joined: 2003-01-19 04:50pm
Location: Lower A-Frame and Watt's linkage

Post 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()
User avatar
haas mark
Official SD.Net Insomniac
Posts: 16533
Joined: 2002-09-11 04:29pm
Location: Wouldn't you like to know?
Contact:

Post by haas mark »

Thanks. :)

~ver
Robert-Conway.com | lunar sun | TotalEnigma.net

Hot Pants à la Zaia | BotM Lord Monkey Mod OOK!
SDNC | WG | GDC | ACPATHNTDWATGODW | GALE | ISARMA | CotK: [mew]

Formerly verilon

R.I.P. Eddie Guerrero, 09 October 1967 - 13 November 2005


Image
Post Reply