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

HELP!!!

Status
Not open for further replies.

KieTo

Programmer
Dec 19, 2001
3
CA
hi...I am trying to open a new window with a URL that is stored in a database...can someone see what's wrong with this code??? thanks.


<%@ Language=VBScript %>
<!--#include file=&quot;Reborn.inc&quot;-->

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;javascript&quot;>
<!--
function popwindow(URL) {
window.open (URL)
}
-->
</script>


</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form name=&quot;frmIndex&quot;>

<%
dim rsSites
dim query


set rsSites = Server.CreateObject(&quot;ADODB.Recordset&quot;)
query = &quot;select * from tblSites&quot;

rsSites.Open query, objConn, adOpenDynamic, adLockReadOnly, adcmdText
%>


<select name=&quot;mnuSites&quot; onChange=&quot;popwindow(<%=rsSites(&quot;Site_Address&quot;)%>;&quot;>
<option selected><<< More Great Sites >>> </option>
<%do while not rsSites.EOF%>
<option><%=rsSites(&quot;Site_Title&quot;)%></option>
<%
rsSites.MoveNext
loop%>
</select>
<%
rsSites.Close
objConn.Close
set rsSites = nothing
set objConn = nothing
%>


</form>
</body>
</html>
 
Try this..

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function popUp(URL) {
window.open(URL,'toolbar=no,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=810,height=810,left = 1,top = 1');
}
</script>

Rushi Shroff
 
ok ok...I got it to display my link in a new window everytime a user chooses from the list...but my problem right now is I don't think I should be using a session variable for the link. With this code...I'm always left with the last record as the link. I know this is easy but it's been a while since I've done ASP. Do I have to make another function to change the query where now I'm retrieving whichever is selected in the menu and then get the link for that particular item??? I'm sure there's an easier way...but I'd spent the whole night figuring this out...so please give me some hints...thanks.


<script language=&quot;javascript&quot;>
<!--

function popwindow(url) {
window.open (url);
}
-->
</script>


</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form name=&quot;frmIndex&quot;>


<select name=&quot;mnuSites&quot; onChange=&quot;popwindow(<%=Session(&quot;Link&quot;)%> );&quot;>
<%
dim rsSites
dim query, address

set rsSites = Server.CreateObject(&quot;ADODB.Recordset&quot;)
query = &quot;select * from tblSites&quot;

rsSites.Open query, objConn, adOpenDynamic, adLockReadOnly, adcmdText
%>
<option selected> LINKS </option>
<%
do while not rsSites.EOF%>
<option><%=rsSites(&quot;Site_Title&quot;)%></option>
<%
Session(&quot;Link&quot;) = rsSites(&quot;Site_Address&quot;)
rsSites.MoveNext

loop%>
</select>
<%
rsSites.Close
objConn.Close
set rsSites = nothing
set objConn = nothing
%>

 
The problem is simply that you're trying to mix server and client side scripting.

<select name=&quot;mnuSites&quot; onChange=&quot;popwindow(<%=rsSites(&quot;Site_Address&quot;)%>;&quot;>

should become something like

<select name=&quot;mnuSites&quot; onChange=&quot;popwindow(frmIndex.mnuSites.options[frmIndex.mnuSites.selectedIndex].text)&quot;>

codestorm
Fire bad. Tree pretty. - Buffy
Hey, I'm operating on a limited mental budget here.
<insert witticism here>
 
But am I able to pass the function the link which is stored in my database??? Or do I have to query the database again and retrieve the link from the database before I can use the popwin()??? Hope I'm clear on this...thanks.
 
Let's see... try:

<select name=&quot;mnuSites&quot; onChange=&quot;popwindow(frmIndex.mnuSites.options[frmIndex.mnuSites.selectedIndex].text)&quot;>
>
<%
dim rsSites
dim query, address

set rsSites = Server.CreateObject(&quot;ADODB.Recordset&quot;)
query = &quot;select * from tblSites&quot;

rsSites.Open query, objConn, adOpenDynamic, adLockReadOnly, adcmdText
%>
<option selected> LINKS </option>
<%
do while not rsSites.EOF%>
<option value=&quot;<%=rsSites(&quot;Site_Address&quot;)%>&quot;><%=rsSites(&quot;Site_Title&quot;)%></option>
<%
rsSites.MoveNext

loop%>
</select>

codestorm
Fire bad. Tree pretty. - Buffy
Hey, I'm operating on a limited mental budget here.
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top