Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open a new window in a list box

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How can I make the link open in a new window inthe following script?:

<script LANGUAGE=&quot;JavaScript&quot;>
<!--
function menu(list)
{
location.href = list.options[list.selectedIndex].value
}
// -->
</script>
<form NAME=&quot;links&quot;><select><option VALUE=&quot;no link&quot;><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;Select a Song Title</i>
<option VALUE=&quot;sorry.htm&quot;>-Cyclops
<option VALUE=&quot;sorry.htm&quot;>-Hell No
<option VALUE=&quot;sorry.htm&quot;>-Gods of War
<option VALUE=&quot;tabs/picasso/1000.htm&quot;>-1000 Points of Light
<option VALUE=&quot;sorry.htm&quot;>-Laughing in the Hiding Bush
<option VALUE=&quot;sorry.htm&quot;>-Change of Heart
<option VALUE=&quot;sorry.htm&quot;>-Shoot all the Clowns
<option VALUE=&quot;sorry.htm&quot;>-Fire
<option VALUE=&quot;tabs/picasso/sacredcowboys.htm&quot;>-Sacred Cowboys
<option VALUE=&quot;tabs/picasso/dragon.htm&quot;>-Tears of the Dragon

</select><input TYPE=&quot;button&quot; VALUE=&quot;Go!&quot;
onClick=&quot;menu(this.form.elements[0])&quot;></form>

Thanks for any help
 
Take a look at the following sample page. I think you will be able to adapt it to what you want to do.

<html>
<head>
<script language=&quot;Javascript&quot;>
function new_window(){

var sLocation
sLocation = document.frmTest.lstLinks.value;

if (sLocation!=&quot;welcome message&quot;){
window.open(src=sLocation);
}
}
</script>
</head>
<body>
<form name=&quot;frmTest&quot; action=&quot;test3.html&quot; method=&quot;POST&quot;>
<select onchange=&quot;new_window(); return true;&quot; name=&quot;lstLinks&quot;>
<option value=&quot;welcome message&quot;>Select a link
<option value=&quot;test2.html&quot;>test2
</select>
<input type=&quot;Button&quot; onclick=&quot;new_window(); return true;&quot;>
</form>
</body>
</html>


Simon
 
Sorry to bother again, but I keep getting a &quot;null&quot; value for the link when I run the above script. I can't seem to adapt it without getting the same error either.

Thanks,
Koggie
 
change the menu function to look like this:

function menu(list)
{
surl=list.options[list.selectedIndex].value
mnuwin=window.open(surl,&quot;menuwin&quot;,&quot;options&quot;)
}

you can now communicate with the popup window by saying mnuwin.whatever jared@aauser.com
 
Sorry - I made a mistake by leaving the button on the page (this is an overhang from a previous test!!) The button does not come into it at all; just select an entry in the list, and a new window should open.

I have just copied the script to a new file, and it worked, as is (less the button issue).

As jaredn says, if you do mnuwin=window.open(...) you can then interact with the new window, but I have not been able to get surl=list.options[list.selectedIndex].value to work.

Simon
 
I'm a little confused on where I'm supposed to use the mnuwin.whatever.

Thanks again.

 
In my first post on this thread, replace the line

window.open(src=sLocation);

with

mnuwin=window.open(src=sLocation);

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top