By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

JavaScript and ASP variables

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a


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

P: n/a
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.