Problem: to open a new window with the select -option
<form onsubmit="return handleSubmit()" target="_blank" method="get" name="moduleForm" id="moduleForm">
<font size=2 face = verdana color= #0000ff ><b>Search</b></font>
<select name="allSelect" id="allSelect">
<optgroup label="Historical">
<option value="http://www.something.com/cse?cx=0000000000000&sa=Search&q=">Open in a new window 1</option>
<option value="http://www.google.com/cse?cx=0000000000000000A-cmjrngmyku&ie=UTF-8&sa=Search&q=">Open in a new window 2</option>
</optgroup>
</select>
<input type="text" name="allQuery" id="allQuery" size="22" />
<input type="submit" value=" Go " />
Question: How can I open the content to a new window with a select-box?
Keep in mind that your page should be usable without scripting, so I'd suggest implementing a fallback mechanism: The form should call a server-side script which responds with a
30x
status and aLocation
header.The client-side would look like this:
Also, remember that
target="_blank"
/window.open()
is often evil.Modify your
handleSubmit
function as follows:You can open your links by window.open() :
Give a look to the window.open function.