469,352 Members | 1,661 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

JavaScript and ASP variables

I want to increment a ASP variable by 1, each time I click on a A HREF
(by onClick). Is that at all possible in any way?

Michael K. P.
Jul 23 '05 #1
3 1294
Michael Kragh Pedersen wrote:
I want to increment a ASP variable by 1, each time I click on a A HREF
(by onClick). Is that at all possible in any way?


You need to make an HTTP request to the server so that the ASP is executed
again.

The simpliest way to do this is: <a href="foo.asp?foo=4"> where '4' is
generated by the ASP script.

No JavaScript involved.

You could do more complex things with XMLHTTP, but that results in reduced
browser support.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #2


Michael Kragh Pedersen wrote:
I want to increment a ASP variable by 1, each time I click on a A HREF
(by onClick). Is that at all possible in any way?


<a href="add.asp">add</a>

then add.asp increments the (Session?) variable and makes sure it
doesn't send a response body by setting the correct HTTP response header
e.g.
Response.Status = "204 no content"
That way when the link is clicked the browser makes the HTTP request to
the server for add.asp but as long as the server answers with 204 as the
HTTP response status code the page with the link is not changed.

That has nothing to do with client-side JavaScript then obviously.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3
David Dorward wrote on 19 feb 2005 in comp.lang.javascript:
Michael Kragh Pedersen wrote:
I want to increment a ASP variable by 1, each time I click on a A
HREF (by onClick). Is that at all possible in any way?


You need to make an HTTP request to the server so that the ASP is
executed again.

The simpliest way to do this is: <a href="foo.asp?foo=4"> where '4' is
generated by the ASP script.

No JavaScript involved.

You could do more complex things with XMLHTTP, but that results in
reduced browser support.


=== test.html:

Only this iframe will refresh:<br>
<iframe src="test.asp"></iframe>

==================================

=== test.asp:

<%
Response.Expires = 0
if session("count") = "" then session("count") = 0
session("count") = session("count")+1
%>

Count is now: <%=session("count")%><br>

<a href="test.asp">Click to increment</a>

===================================

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jay | last post: by
12 posts views Thread by mbasil7 | last post: by
8 posts views Thread by mantrid | last post: by
10 posts views Thread by John Passaniti | last post: by
pbmods
1 post views Thread by pbmods | last post: by
2 posts views Thread by sorobor | last post: by
20 posts views Thread by shapper | last post: by
3 posts views Thread by q-rious | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.