View Full Version : ASP/JS Mix Question
Shade
05-15-2003, 03:36 PM
I am the quasi-web designer for a catering company based out of Columbus, OH. On our website, we have almost every menu item well sell listed, using an access dB with asp. I had an idea to have every menu item's title clickable, so that once clicked, the user could see a picture of that menu item. The only problem I can see with this is the reference that each link would have to refer to my javascript, which would have to have a different link. Now, I have a unique number for each menu item, so it seems that I could use that number with the javascript link to distinguish between each menu item's link. The only question is how do I do this? Sorry if this doesn't make sense, but I'm kinda new to JS, and I don't knoiw the terminology very well. Thanks in advance for the help!
Rob
P.S. vitoscatering.com is the website, if you'd like a link.
allida77
05-15-2003, 03:59 PM
function openpopup(id){
var popurl="viewitem.asp?mnuItemID=" + id
winpops=window.open(popurl,"","width=650,height=650,scrollbars,resizable,")
}
When looping through your menu items just pass the item id with the openpopup function. e.g.
Response.Write"<a href='javascript: openpopup('" & rs("mnuID") & "')'></a>")
nice web site it makes me hungry.
Shade
05-15-2003, 04:17 PM
Originally posted by allida77
function openpopup(id){
var popurl="viewitem.asp?mnuItemID=" + id
winpops=window.open(popurl,"","width=650,height=650,scrollbars,resizable,")
}
When looping through your menu items just pass the item id with the openpopup function. e.g.
Response.Write"<a href='javascript: openpopup('" & rs("mnuID") & "')'></a>")
nice web site it makes me hungry.
Kinda what I whipped up real quick:
function openpic(<%=num%>){
var popurl="images/<%=pic3%>"
winpops=window.open(popurl,"","width=650,height=650,scrollbars,resizable,")
<a href="javascript: openpic(<%=num%>)"><%=items%> </span></a>
I saw in your JS script that you had the menu item's number defined. I already had it assigned, kinda cheating from my designer's technique ;) I think that might be why I'm getting errors...
Thanks, BTW, that's the idea :D
Here's (http://www.vitoscatering.com/submenu2.asp?menu=001A&submenu=001B) the test site I whipped up real quick.
allida77
05-15-2003, 04:36 PM
Im sorry I may have lead you down a wrong path.You only need one js function:
function openpic(url){
var popurl=url
winpops=window.open(popurl,"","width=650,height=650,scrollbars,resizable,")
}
Now in all the links you have you will call this same js function just passing different values for the "url" argument.
<a href="javascript:openpic('images/<%=pic3%>')"><%=items%></a>
<a href="javascript:openpic('images/<%=pic4%>')"><%=items%></a>
<a href="javascript:openpic('images/<%=pic5%>')"><%=items%></a>
ect...
Shade
05-15-2003, 04:52 PM
Well, wait, I don't think that will work, becuase I have one variable for all of the menu item's names. That's why I was saying that I would have to use the menu item's number to reference the picture. pic3 is just a variable for the reference to the picture's name:
<%
Set itemsRS = Server.CreateObject( "ADODB.Recordset" )
itemsRS.ActiveConnection = objConn
fieldcode = "X"&code2
sqlString = "SELECT ITEM_NAME, ITEM_DESC, ITEM_PRICE, ITEM_PIC, ITEM_NUM FROM MENU_CODES WHERE " & fieldcode & " = true"
itemsRS.Open sqlString, objConn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<%
counter = 0
WHILE NOT itemsRS.EOF
pic3 = itemsRS("ITEM_PIC")
num = itemsRS("ITEM_NUM")
items = itemsRS("ITEM_NAME")
desc = itemsRS("ITEM_DESC")
price = itemsRS("ITEM_PRICE")
%>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.