PDA

View Full Version : Passing Javascript to ASP


Gail1111
04-28-2003, 05:24 PM
I have two pages. Page one sends info via a Javascript prompt to page Two which receives the info into ASP code that generates a query statement-so far okay. Users get from Page One to Page Two using a text link.

Now, if page Two is loaded directly, I need to add to Page Two its own Javascript prompt that will take the input and pass it to the same ASP code to place inside a query statement (on the same page).

I am using a Session variable to hold the value that is being passed to the SQL statement.
this is what I have been trying:
<script language="javascript">
<!--
var PageTwoValue
PageTwoValue = prompt("your id","");
//
</script>

blah blah blah

<%
Session("id") = PageOneValue
Session("id") = PaeTwoValue

SQL statement using Session("id")

SQL results.
%>

I REALLY would appreciate help on this coding problem.
TY.
Gail1111:confused:

boywonder
04-28-2003, 05:41 PM
Your client side Javascript and ASP code do not run simultaneously. By the time that JS Prompt shows up in the browser, all your ASP code in that page has long since been executed...

tack the values on to the url like so

wwwblah.com/blah.asp?PageOneValue=something&PageTwoValue=whatever

or use a regular form with GET/POST

Then read it back on the server as Request("PageTwoValue")

make sense?

Gail1111
04-28-2003, 06:09 PM
No, it does not make sense to me, yet. How can I use the GET/POST method for data on the same page?

boywonder
04-28-2003, 08:16 PM
You can post a form back to itself so the user input can be implemented with your ASP script in the same page. It's quite common. But the values have to be sent to the server for processing.

This might be helpful
http://www.w3schools.com/asp/asp_inputforms.asp

Gail1111
05-05-2003, 09:39 PM
Thank You. I was able to get the pages up and running.

Gail1111 :)