|
 |
asp_web_howto thread: Passing Variable From JavaScript to ASP
Message #1 by George Smyth <george.smyth@U...> on Tue, 24 Apr 2001 14:55:10 -0400
|
|
I am sure that this question must have been asked before, but I need to know
how to pass a JavaScript variable to ASP.
When people register on our site, we may or may not already have their email
address. 95% of the registration problems occur when people enter a wrong
email address (transpose letters, whatever).
When they submit the HTML form, as ASP program does a number of things
before allowing them to register. I am adding to that something to see if
the email address they have entered already matches what we have. If this
is the case, then fine. If not, I want to pop up a JavaScript prompt
asking them to confirm the entry of their email address. I can then compare
when they entered in the JavaScript prompt to what they entered through the
form, which should catch most of these.
So far, so good.
The only problem I have at this moment is understanding exactly how to pass
what they have entered through the prompt to the ASP portion of the program.
Any help here?
The code is simply this:
' If no match was found, ask for a confirmation
If EmailExists = False Then
Response.Write "<script language=JavaScript>"
Response.Write " var ConfirmEmail = prompt('Please confirm your email
address by entering it here.');"
Response.Write "</script>"
End If
Thanks -
George L Smyth, Webmaster
US Naval Academy Alumni Association
Message #2 by "George Draper" <georgedraper@m...> on Tue, 24 Apr 2001 17:19:45 -0400
|
|
Since you have to go to the database via the server to check if the email
address is already there, you only need to add the action to the asp page
that processes the original form. If the address is not in the database,
you add their information and if it is in the database you respond with a
page that says 'You are already in our database. Would you like to edit your
profile?' or something like that. Major problem with this is that email
addresses are not unique. e.g. jsmith@y... may be dropped by one
person and be taken later by another. So you don't want to assume it is the
same person or you will be giving someone's personal information to the
wrong person as well as creating all sorts of data reliability problems.
You should have some other unique identifier used in the process.
You should map out the whole process. Then program it.
- George
-----Original Message-----
From: George Smyth <george.smyth@U...>
To: ASP Web HowTo <asp_web_howto@p...>
Date: Tuesday, April 24, 2001 3:13 PM
Subject: [asp_web_howto] Passing Variable From JavaScript to ASP
>I am sure that this question must have been asked before, but I need to
know
>how to pass a JavaScript variable to ASP.
>
>When people register on our site, we may or may not already have their
email
>address. 95% of the registration problems occur when people enter a wrong
>email address (transpose letters, whatever).
>
>When they submit the HTML form, as ASP program does a number of things
>before allowing them to register. I am adding to that something to see if
>the email address they have entered already matches what we have. If this
>is the case, then fine. If not, I want to pop up a JavaScript prompt
>asking them to confirm the entry of their email address. I can then
compare
>when they entered in the JavaScript prompt to what they entered through the
>form, which should catch most of these.
>
>So far, so good.
>
>The only problem I have at this moment is understanding exactly how to pass
>what they have entered through the prompt to the ASP portion of the
program.
>Any help here?
>
>The code is simply this:
>
> ' If no match was found, ask for a confirmation
> If EmailExists = False Then
> Response.Write "<script language=JavaScript>"
> Response.Write " var ConfirmEmail = prompt('Please confirm your email
>address by entering it here.');"
> Response.Write "</script>"
> End If
>
>Thanks -
>
>George L Smyth, Webmaster
>US Naval Academy Alumni Association
>
>
Message #3 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Wed, 25 Apr 2001 10:15:52 +0100
|
|
you have to submit it back to the server through get or post. the asp will
continue to execute beyond the point where you write the code to create the
prompt, and will have finished executing by the time the user gets the
prompt. All you can do is place whatever they put in the prompt into a
hidden input field and re-submit the page.
-----Original Message-----
From: George Smyth [mailto:george.smyth@U...]
Sent: Tuesday, April 24, 2001 7:55 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Passing Variable From JavaScript to ASP
I am sure that this question must have been asked before, but I need to know
how to pass a JavaScript variable to ASP.
When people register on our site, we may or may not already have their email
address. 95% of the registration problems occur when people enter a wrong
email address (transpose letters, whatever).
When they submit the HTML form, as ASP program does a number of things
before allowing them to register. I am adding to that something to see if
the email address they have entered already matches what we have. If this
is the case, then fine. If not, I want to pop up a JavaScript prompt
asking them to confirm the entry of their email address. I can then compare
when they entered in the JavaScript prompt to what they entered through the
form, which should catch most of these.
So far, so good.
The only problem I have at this moment is understanding exactly how to pass
what they have entered through the prompt to the ASP portion of the program.
Any help here?
The code is simply this:
' If no match was found, ask for a confirmation
If EmailExists = False Then
Response.Write "<script language=JavaScript>"
Response.Write " var ConfirmEmail = prompt('Please confirm your email
address by entering it here.');"
Response.Write "</script>"
End If
Thanks -
George L Smyth, Webmaster
US Naval Academy Alumni Association
________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com
|
|
 |