471,595 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

Getting value of a var from javascript back to ASP

Hi,

I have this function:

<script type="text/javascript">
function disp_prompt() {
var reqid=prompt("Please enter the membership ID number","")
if (reqid!=null && reqid!="") {
reqid=reqid
}
}
</script>

That produces a prompt to prompt for a number, how can i return the
value (reqid) back to ASP so i can then use it within ASP for database
querys? This has to be very simple and just a pop-up box to ask for the
number and return it back for processing.

Ive tried this with no success.

<%
%snip%
response.write "<script>javascript:disp_prompt()</script>"
TidF=reqid
TidFi=INT(TidF)
%snip%

strSQL = "SELECT [FIRST NAME] AS fn, SURNAME AS sn, PHOTO AS
ph, [ID] AS idn FROM MEMBERS WHERE [ID] = "&TidFi&" "

%snip%

%>

Any light on this would be great thanks!

Luke.
Oct 18 '06 #1
2 1269
Hi,

Luke - ea********@gmail.com wrote:
Hi,

I have this function:

<script type="text/javascript">
function disp_prompt() {
var reqid=prompt("Please enter the membership ID number","")
if (reqid!=null && reqid!="") {
reqid=reqid
}
}
</script>

Before you try any more, you need to seriously work on understanding the
web paradigm, especially the request/response model. As your example
shows, you think that the server code and the client code are executed
simultanously. However, this is not the case. The server produces
client-side code (typically HTML, JavaScript and CSS), then sends it to
the client. From this moment on, the server doesn't work anymore until
the next request arrives.

The code sent to the client is parsed and interpreted, and JavaScript
code, if available, is executed. If you want to communicate the result
of a JavaScript action to the server, you need to send a new request to
the server, with the information. You have different ways to do that,
for example by POSTing a request and saving the information in a hidden
field (or a text field). Another way is to use GET, i.e. to set the
window.location object with a parameter (query string).

I think that you need to understand all this first, and then do a few
small tests to see how that works.

Good luck,
Laurent
That produces a prompt to prompt for a number, how can i return the
value (reqid) back to ASP so i can then use it within ASP for database
querys? This has to be very simple and just a pop-up box to ask for the
number and return it back for processing.

Ive tried this with no success.

<%
%snip%
response.write "<script>javascript:disp_prompt()</script>"
TidF=reqid
TidFi=INT(TidF)
%snip%

strSQL = "SELECT [FIRST NAME] AS fn, SURNAME AS sn, PHOTO AS ph,
[ID] AS idn FROM MEMBERS WHERE [ID] = "&TidFi&" "

%snip%

%>

Any light on this would be great thanks!

Luke.

--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 18 '06 #2
<ea********@gmail.comwrote in message
news:M7******************************@eclipse.net. uk...
That produces a prompt to prompt for a number, how can i return the value
(reqid) back to ASP so i can then use it within ASP for database querys?
This newsgroup is for issues related to ASP.NET.

For ASP questions, please post on: microsoft.public.inetserver.asp.general
Oct 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dan glenn | last post: by
1 post views Thread by MickG | last post: by
4 posts views Thread by My Pet Programmer | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

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.