|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Unfortunately, that's not me. I've never worked in asp and I'm working with old code that someone else wrote. Anyway, here is the problem; I have this javascript:
<script language="javascript"> function openPopup(strOpen) { open(strOpen, "Info", "status=1, width=600, height=500, top=200, left=100"); } </script> I have this in the page: <% response.write "<a href='popup.aspx?productid="&rs_products.fields("productid") &"'> Product Information: " & "</a><br>" %> I have tried about ten different ways to add the popUp javascript to this piece of code, but it always causes the page to crash. Can someone tell me exactly how to do this? Thanks! |
|
#2
|
||||
|
||||
|
Go here
http://javascript.internet.com/generators/popup-window.html Enter your information and generate new popup code. At the very least the code in your link should look like this: Code:
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=1,width=600,height=500,left = 540,top = 275');");
}
// End -->
</script>
For the link: Code:
response.write "<A HREF=""javascript:popUp(""popup.aspx?productid="&rs_products.fields("productid")&")"">Product Information:</A>"
You might have to play around with the quote marks. If you can't get it, then just remove the response.write and do it like this: Code:
%>
<A HREF="javascript:popUp(''popup.aspx?productid="&rs_products.fields("productid")')">Open the Popup Window</A>
<%
Last edited by mystic7 : June 24th, 2009 at 04:53 PM. |
|
#3
|
|||
|
|||
|
Thanks! I'll let you know if it works out. I can do these things in asp.net but for some reason asp baffles me.
|
|
#4
|
|||
|
|||
|
I implemented the code, here is the page:
the page is not throwing an error now, but when you click on the link with the popup, the url that comes up is javascript opUp(I tried every way I can to rearrange the quote marks, including using single quotes, but it doesn't work? Any suggestions? Thank you very much for helping. ---------- Code:
<!--#include file="shoppage_header.asp"-->
<head>
<style type="text/css">
.style1
{
width: 29%;
}
.style2
{
width: 38%;
margin-left: 36px;
}
</style>
</head>
<script language="javascript">
function ChangeForm()
{
document.form2.action="displayproducts.asp?catid="+document.form2.page.value+"&page_size="+document.form2.page_size.value;
document.form2.submit();
}
</script>
<script language="javascript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0, scrollbars=0, location=0, statusbar=0, menubar=0, resizable=1, width=600, height=500,l eft=540, top=275');");
}
</script>
<script language="javascript">
function openPopup(strOpen) {
open(strOpen, "Info", "status=1, width=700, height=700, top=50, left=50, scrollbars=yes, resizable=1");
}
</script>
<%
dim catid, page_size
catid = request.querystring("catid")
if request.QueryString("page_size") <> "" Then
session("page_size") = cint(request.QueryString("page_size"))
End If
If trim(session("page_size")) = "" Then
session("page_size") = 25
End If
%>
<body>
<td rowspan="0" colspan="0" valign="top">
<br>
<table width="625" border="0" style="margin-left: 48px">
<form name="form2" method="post">
<tr>
<td width="25%" height="41">
<%
dim RsRecordTable
%>
<select name="page" class="pagedropdown" onChange="ChangeForm();">
<%
sql= "select categoryid, categoryname from categories order by categoryid"
'set rs = con.execute(sql)
' set RsRecordTable = server.CreateObject("adodb.recordset")
' RsRecordTable.open sql, strconnect
Set RsRecordTable = server.CreateObject("adodb.recordset")
RsRecordTable.open sql, strconnect
If catid <> "" Then
Dim rs_cat
set rs_cat = server.CreateObject("adodb.recordset")
rs_cat.open "select categoryid, categoryname from categories where categoryid='"& catid &"'", strconnect
if not rs_cat.eof Then
response.Write"<option value="& rs_cat.fields("categoryid")&">"& rs_cat.fields("categoryname")&"</option>"
Else
response.Write"<option >--Select--</option>"
End If
rs_cat.close
set rs_cat = nothing
End If
while NOT RsRecordTable.eof
If cint(catid) <> RsRecordTable.fields("categoryid") Then
response.Write"<option value="& RsRecordTable("categoryid") &">"& RsRecordTable("categoryname") &"</option>"
End If
RsRecordTable.MoveNext
wend
RsRecordTable.close
set RsRecordTable = nothing
%>
</select> </td>
<td class="style2"> </td>
<td width="46%">
<span class="style1"># of items:</span> <select name="page_size" id="page_size" onChange="ChangeForm();">
<% if session("page_size") = 25 Then %>
<option value="25">25</option>
<option value="75">75</option>
<option value="100">100</option>
<% elseif session("page_size") = 75 Then %>
<option value="75">75</option>
<option value="25">25</option>
<option value="100">100</option>
<% else %>
<option value="100">100</option>
<option value="25">25</option>
<option value="75">75</option>
<% End If %>
</select></td>
</tr>
</form>
</table>
<table border="0" bgcolor="#EDB111"
style="height: 15px; width: 700px; margin-left: 48px;">
<tr>
<td width="25%"><span style="color: #FFFFFF; font-weight: bold;"> Item</span></td>
<td width="53%"> </td>
<td width="22%"> </td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0"
style="width: 697px; margin-left: 48px;" >
<tr>
<%
dim categoryname(10000), i
i=0
dim rs_products
set rs_products = server.CreateObject("adodb.recordset")
rs_products.CursorType = 1
rs_products.open "select * from products where categoryid='"& catid &"' order by productname", strconnect
'''''Paging''''''''
DIM intPageRecords, intRecords, intRecordCount, intCurrentPage
DIM intNumberOfPages, intDisplayPage
intPageRecords = Request.Querystring("page")
IF intPageRecords = "" THEN intPageRecords = 1 : intRecords = 1
intRecords = intPageRecords
intPageRecords = ((intPageRecords - 1) * session("page_size") ) +1
intRecordCount = 0
IF NOT rs_products.EOF THEN
rs_products.Move (intPageRecords - 1)
Do WHILE intRecordCount < session("page_size") and NOT rs_products.eof
i=i+1
%>
<form name="form1" id="form1" method="post" action="shopaddtocart.asp?action=add">
<% If (i mod 2) = 0 then %>
<tr bgcolor="#f7f7de">
<td style="margin-left: 48px">
<table width="381">
<tr height="40px;">
<td align="left" valign="top" width="400" >
<%
response.write rs_products.fields("productname") & "<br>"
' categoryname(i) = rs_products.fields("categoryname")
%>
</td>
<td width="146" align="right" valign="top">
<%
response.write "<a href=""javascript:popUp(""popup.aspx?productid="&rs_products.fields("productid")&")"">Product Information:</a>"
%>
</td>
</tr>
</table>
</td>
<td valign="top">
<table border="0" style="width: 95%; height: 47px">
<tr>
<td width="26%" height="12" valign="bottom"><div align="right"></div></td>
<td width="74%" rowspan="2" valign="middle">
<input name="orderquantity" type="text" id="orderquantity" value="1" size="2" />
<input name="productid" type="hidden" value="<%=rs_products.fields("productid")%>" />
<input name="submit2" type="image" src="Buttons/buy.jpg" width="70" height="18">
</td>
</tr>
<tr>
<td height="50%"><div align="right"></div></td>
</tr>
</table>
</td>
</tr>
<% else %>
<tr >
<td style="margin-left: 48px">
<table width="381">
<tr height="40px;">
<td align="left" valign="top" width="400" >
<%
response.write rs_products.fields("productname") & "<br>"
' categoryname(i) = rs_products.fields("categoryname")
%>
</td>
<td width="146" align="right" valign="top">
<%
response.write "<a href='popup.aspx?productid="&rs_products.fields("productid") &"'> Product Information: " & "</a><br>"
%>
</td>
</tr>
</table>
</td>
<td valign="top">
<table height="100%" border="0" style="width: 95%">
<tr>
<td width="26%" height="12" valign="bottom"><div align="right"></div></td>
<td width="74%" rowspan="2" valign="middle">
<input name="orderquantity" type="text" id="orderquantity" value="1" size="2" />
<input name="productid" type="hidden" value="<%=rs_products.fields("productid")%>" />
<input type="image" src="Buttons/buy.jpg" name="submit2">
</td>
</tr>
<tr>
<td height="50%"><div align="right"></div></td>
</tr>
</table>
</td>
</tr>
<% End If %>
</form>
<%
If (i mod 2) = 0 then
response.write "</tr><tr>"
end if
rs_products.movenext
intRecordCount = intRecordCount +1
Loop
End if
%>
</table>
</table>
</tr>
</table>
</td>
</tr>
</table>
</td>
<p align="center" style="width: 625px">
<%
intCurrentPage = Request.Querystring("page")
IF intCurrentPage = "" THEN intCurrentPage = 1
intNumberOfPages = int(rs_products.RecordCount \ session("page_size") )
response.write "<br><br><br>"
IF rs_products.RecordCount MOD session("page_size") <> 0 THEN intNumberOfPages = intNumberOfPages + 1
Response.Write("<b>Pages: [</b>")
FOR intDisplayPage = 1 TO intNumberOfPages
IF Cint(intDisplayPage) = Cint(intCurrentPage) THEN
Response.Write " <b>" & intDisplayPage & "</b> "
ELSE
Response.Write " <a class=""smallredtext"" href=""displayproducts.asp?catid="& catid &"&page=" & intDisplayPage & """>" & intDisplayPage &_
"</a> "
END IF
NEXT
Response.Write ("<b>]</b>")
%>
</p>
<%
rs_products.close
set rs_products = nothing
%><!--#include file="footer.asp"-->
---------- Last edited by sync_or_swim : June 26th, 2009 at 09:35 AM. Reason: Added code tags |
|
#5
|
||||
|
||||
|
Go to the link I gave you and generate the code yourself. I may have messed up some quote marks when I tried to rig it for a response.write. Do the code yourself and copy and paste where needed. I've never had a problem using that popup generator.
|
|
#6
|
||||
|
||||
|
--> Moved to Javascript forum
Your problem is that you seem to be using the href property of the hyperlink, you need to use the onclick event, try this: Code:
<script language="javascript">
function openPopup(strOpen) {
open(strOpen, "Info", "status=1, width=600, height=500, top=200, left=100");
}
</script>
<%
Response.Write("<a href=""#"" onclick=""javascript:openPopup('popup.aspx?productid="&rs_products.fields("productid") &"');""> Product Information</a><br>")
%>
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > JScript - General - Error - Simple for someone who knows what they are doing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|