Jump to content

Unable to open url in new windows


NumberTWO
 Share

Recommended Posts

Hi,This codes somehow do no open a new windows whenever I click on the option in the dropdown box. Is there anything I can do ?

<html><body><div align="center"><form action="employment/dummy" method="post"><select name="choice" size="1" onchange="document.location.href=this.options[this.selectedIndex].value;" >    <option value="Select a Country"><b><font face="sans-serif"><font size="3">Select a Country </font></b></option>    <option value="http://www.worldvision.org.uk/"><b><font face="sans-serif">United Kingdom </font></b></option>                             </select></form></div></body></html>
Your help is much appreciated.
Link to comment
Share on other sites

<select name="choice" size="1" onchange="window.open(this.options[this.selectedIndex].value)" >

or simply

<select name="choice" size="1" onchange="window.open(this.value)" >

Link to comment
Share on other sites

edit: removed all, Scott wrotes same as I, again! :) if need to reset selection:

<select name="choice" size="1" onchange="if (this.selectedIndex != 0) window.open(this.value); return this.selectedIndex = 0" >

I mean if You have:<option value="#">Select location</option><option value="http://www.fi/">Mother knows everything</option><option value="http://www.ru/">Russia on the Net</option>etc . select will be reseted to Select location option (o) after each changeUse function,Javascript to head part of Your document:

<script type="text/javascript"><!--function Open(obj){if (obj.selectedIndex != 0) window.open(obj.value);obj.selectedIndex = 0;}//--></script>

HTML:<select onchange="Open(this)">

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...