PDA

Click to See Complete Forum and Search --> : Another cookie question


JasonS
Jan 10th, 2001, 04:28 PM
I have a web page that connects to a database (SQL server) and loops through the data and generates a list of links to go to different areas of the site.

When the user clicks the link I want to write a cookie so I know whick link they selected. Here's how the link is created.

<a href="Profile.asp?Action=View&CId=<%=rs("tpClientId")%>&PId=<%=rs("tpProjectid")%>" name=tqproject language=vbscript onclick='buildname(<%Response.Write(chr(34) & rs("ptProjectDesc") & chr(34))%>)'><%=rs("ptProjectDesc")%></a>

This calls the function just fine but, using response.cookies causes an error (see below). I suppose it's something to do with client/server side processing but I don't know.

I don't want to use jscript to write the cookie (I'm using jscript in other areas just don't want to here, server seems much simpler).

I've tried without the language= and other version but can't get it to work. Here's the latest buildname function.

<script language=vbscript>
sub buildname(sName)
Response.Cookies("ProjName")=sName
end sub
</script>

I'm not using the <form> tag. Will use it if required.
I'm using ASP.

G.Kumaraguru
Jan 10th, 2001, 04:54 PM
onclick='buildname(xxx)'



<script language=vbscript>
sub buildname(sName)
Response.Cookies("ProjName")=sName
end sub
</script>



Response object is Not Part of VBSCRIPT .. It is Part of ASP

There fore It will not WORK !

JasonS
Jan 11th, 2001, 08:31 AM
I knew it didn't work, but I'm looking for a solution to the task I've outlined.

Can anyone point me in a direction to make this work(with whatever language, vbscript,jscript,asp).

JoshT
Jan 11th, 2001, 08:59 AM
From the server side, you would have to set the cookie before you send any HTML code (ie - Response.Write) as Cookies are sent as HTTP headers. So what you need to do is set the cookies on the page linked to, using the HTTP_REFERER Server Variable if needed to tell where the link came from.

Josh