Click to See Complete Forum and Search --> : link - change variable


nookiemon
04-25-2006, 04:20 PM
I've got in over my head with this scripting methinks :P

So I'm going back to basics

So how would a link be set up to change a variable within a page.

I.e. say my page was called info.asp

I have the real simple code


<%
g = 20
response.write g
%>


So 20 is returned. So how do i put in a link into info.asp that will make g+1, and then once clicked run the script to return 21.

I thought it might be


<a href="info.asp?g=g+1">Amended g</a>


But it doesnt work. Hoping someone can help me with this probably basic but fundamental question.

Thanks

russell
04-25-2006, 04:31 PM
Dim g

g = Request.QueryString("g")

If len(g) Then
g = clng(g)
Else
g = 1 '' or whatever default you want
End If

Response.Write "<a href=""info.asp?g=" & g+1 & """>Amended</a>" & vbCrLf

nookiemon
04-25-2006, 05:05 PM
Thanks for the reply russell.

This error message comes up

Response.Write "<a href=""info.asp?g=" & g+1 & """>Amended</a>" & vbCrLf g
-------------------------------------------------------------------------^

Is it to do with the various " and my server I'm using?

chrismartz
04-25-2006, 05:56 PM
That last g shouldn't be on there after the & vbCrLf.