Getting value of a var from javascript back to ASP

L

Luke - eat.lemons

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.
 
L

Laurent Bugnion

Hi,
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.
 
M

Mark Rae

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top