473,549 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1394
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?f oo=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.javas cript:
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?f oo=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.Expire s = 0
if session("count" ) = "" then session("count" ) = 0
session("count" ) = session("count" )+1
%>

Count is now: <%=session("cou nt")%><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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2061
by: Jay | last post by:
Hi everybody !! I am just wondering if Javascript and PHP can interact with each other ? Let's say i have a variable in Javascript ( call it "var x = 6;") Is there anyway that we can use "x" value (which is 6) in PHP code? (let's say I want to print "x" out in PHP script) In general, can Javascript variables interact with PHP code and...
12
25133
by: mbasil7 | last post by:
Hi at all! I want to use a javascript variable in php. The reason is that i want to know the client's screen resolution. Here is the code i'm using: <head> <script language='JavaScript'> <!-- var a=(screen.width-750)/2;
22
4576
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last month I had enough of extra proof that the cat doesn't hount mice anymore in more and more situations. And the surrent sicretisme among array and...
8
2374
by: mantrid | last post by:
Hello I have the following code, where clicking yh1r is supposed to move h1 10px down and update the value of yh1 by 20 each time its clicked. what the code actually does is NOT move h1 and instead of incrementing yh1 from 0 to 20 to 40 etc it doubles it and appends it to the original value each time eg 0 to 20 to 4020 to 804020 to 160804020...
10
12779
by: John Passaniti | last post by:
(Note: This is not the same message I posted a week or so ago. The problem that prevented my previous attempt to work was a silly error in the template system I was using. This is a problem involving variable scope in JavaScript.) I have a lot of code that generates HTML on the fly. This code has tags with id attributes derived from...
1
25630
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that...
2
3140
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early...
4
1304
by: davidson1 | last post by:
Hai Friends, I have a javascript program , as a snow a single picture will fall from above to below in the browser.It is worked properly when my friend was using.Sudennly it is not working ,pl correct if there is any error and send me............... <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript">
20
2265
by: shapper | last post by:
Hello, How to create a namespace in Javascript containing two methods? And how to access those methods? Thanks, Miguel
3
2282
by: q-rious | last post by:
Hello All, 1. I would like to pass some variables (x and y below) from Javascript to PHP, process them in PHP, and return some other variables (a abd b) back to Javascript. --(x,y)-- --(a,b)-- 2. The variables x and y are not known to HTML directly, so I can not pass them to PHP as:
0
7521
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5369
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
764
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.