473,378 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 1313
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dan glenn | last post by:
hi. I want to code a 'preview' function into a guestbook entry page. I can do it with a button that posts, bringing up a whole new page showing a preview of what has been entered, and then the user...
2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
1
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
9
by: ShaneFowlkes | last post by:
Hey guys... I have a form that asks for several dates. I tried using asp calendar controls to set values of the date textboxes which were readonly. I found this annoying since each time I...
10
by: eggie5 | last post by:
Is it possible to get a file without using a form post? I want to get the data (bytes) of a file, text or binary, and just save it to a variable. Similar to the post body of a form that has a...
4
by: My Pet Programmer | last post by:
Ok guys, I'm really looking for someone to tell me how bad a hack this is, and if I'm close to where I should be with it. The basic situation is that I have a class which creates a basic...
4
omerbutt
by: omerbutt | last post by:
hi there i am making an application in which i have a drop down menu which onchange passes a value(this.value) to a js function which gets the value and calls an ajax routine and passes that value...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.