JavaScript onChange Question

admin

Administrator
Staff member
Hello,

I'm fairly new with using the onChange event handler, and have a question. I created an online form that has a pull down options menu. What I like to do is when a user selects an item from the menu, and entirely new browser window will open up.

I currently have a script setup so when a user selects an item from the menu, it forwards them to a web page, but it uses the same browser window the form is using.

Below is the script I'm currently using.

<head>

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from older browsers

function jumpPage(newLoc) {
newPage = newLoc.options[newLoc.selectedIndex].value

if (newPage != "") {
window.location.href = newPage
}
}

// End hiding script from older browsers -->
</SCRIPT>
</head>

<body>
<form name="register" method="post" action="test.cgi">

<SELECT NAME="newLocation" onChange="jumpPage(this.form.newLocation)">

<OPTION VALUE=http://www.webdeveloper.com/forum/archive/index.php/"" SELECTED>United States
<OPTION VALUE="test.html">Other Country
</SELECT>

<NOSCRIPT>
<INPUT TYPE=SUBMIT VALUE="Go There!">
</NOSCRIPT>

</form>
</body>

Any help will be greatly appreciated. :)

Thanks,

Jeremy
 
Back
Top