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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pop up window

Status
Not open for further replies.

dip

Programmer
Aug 15, 2000
20
SG
Hi,
I have just created a function where when the user chooses a field from the drop down menu, it will take them straight to the site. The code was successfully compiled but the problem is how can I open the info in a different window rather than the same window.

Code:
<script language=&quot;JavaScript&quot;>
function SelectIt(){
        if (document.Links.Select.options[document.Links.Select.selectedIndex].value != &quot;none&quot;){ 
        location = document.Links.Select.options[document.Links.Select.selectedIndex].value}        
}
</script>
<html>
<head>
	<title>Untitled</title>
</head>

<body>
<center><h2>Resources booking</h2>
<br>
<table width=&quot;500&quot; border=&quot;0&quot; cellspacing=&quot;6&quot; cellpadding=&quot;0&quot;> 

   <tr>
		<td nowrap>
				<form name=&quot;Links&quot;>
				<div align=&quot;right&quot;> <font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;> 
		<b>Type of Booking			:</b></font></div>
		</td>
		<td><font size=&quot;2&quot;><cfoutput>
	<select NAME=&quot;Select&quot; onchange=&quot;SelectIt()&quot; size=&quot;1&quot;>
						<option value=&quot;none&quot;>[Select A Link] </option>
						<option VALUE=&quot;grid1_new2.cfm&quot;>conference room</option>
    					<option VALUE=&quot;notebook_index.cfm&quot;>notebook</option>
						<option VALUE=&quot;projector_index.cfm&quot;>projector</option>
						<option VALUE=&quot;book.cfm&quot;>Books</option>
						<option VALUE=&quot;grid1.cfm&quot;>CD</option>
						</select></cfoutput>
		</font></td>
   </tr>
	 
</body>
</html>

Thank you.
dip

 
Hi dip!
You should use window.open insted of location.
Of course, with proper syntax.

Andrew | starway@mail.com
 
Hi Dip

An example if you need it:

window.open(&quot;start.html&quot;,&quot;MyWindow&quot;,&quot;toolbar=no,width=630,height=480,directories=no,status=yes,scrollbars=yes,resize=no,menubar=no,left=0,top=0&quot;);
 
Hi Andrew &amp; Modalman,

Thank You for you replies, but unfortunately the codes don't seem to work now as soon as i have replaced the location with window.open. It just doesn't seem to work even after i used the codes given by modalman. I am still new to javascript so is there anything wrong with the codes. Please advice.

Thank You.
dip
 
Replace your function with this:

<script language=&quot;JavaScript&quot;>
function SelectIt(){
if (document.Links.Select.options[document.Links.Select.selectedIndex].value != &quot;none&quot;){
newUrl = document.Links.Select.options[document.Links.Select.selectedIndex].value
window.open(newUrl,&quot;MyWindow&quot;,&quot;toolbar=no,width=630,height=480,directories=no,status=yes,scrollbars=yes,resize=no,menubar=no,left=0,top=0&quot;);
}
}
</script>

This puts the url into a string variable called 'newUrl' instead of the object 'location'.

newUrl is then opened in the new window.
 
Hi Modalman,

Thanks...it is working now.

dip.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top