1

I have a jQuery-powered cost calculator, and I want to allow the webpage to send a summary of the calculator's values in an email. The server runs on classic ASP.

How do I retrieve javascript variables with ASP?

I understand that the ASP code runs before the page loads, and the javascript code runs only after the page is loaded, since the javascript is not runat="server".

How can I store javascript variables so that I can retrieve them with ASP code on a processing page?

calculator with Javascript --> form action = "process.asp" --> ASP to pick up javascript values

College Cost Calculator

2 Answers 2

4

Another solution is to set the values of the javascript variables to hidden form fields. Submit the form and read the form values on the server-side. After reading the values, create and send the email.

Sign up to request clarification or add additional context in comments.

6 Comments

This. ASP works off of form fields or query string variables.
@CM-Kanode, How do I set the values of javascript to hidden form fields? Like this? <input type = "hidden"> And then, would I retrieve these values by "Dim" and Request.Form() in process.asp?
@lukenjohnson Yes, add the needed hidden fields (be certain to set the name attribute) to your form. Use javascript to set the value, and submit the page to the server. In the server-side code, retrieve the value using the request object. "Dim" is used to declare a variable in vbscript, just like "var" is used to declare a variable in javascript. BTW, why are you using classic Asp?
@CMKanode, Thank you! I ended up not having to use hidden fields, but your advice got me searching for things that solved my problem. Using Request.ServerVariables on process.asp I am able to access Javascript variable values from the calculator page. (I am using classic ASP because the institution I work for is unfortunately dedicated to its classic ASP server because so much stuff currently runs on it. Until I have the time to turn it into .NET or PHP, I'm stuck with good old classic ASP.) Thanks for your help!
If anyone else needs this same solution, an example of the ASP that works for me is: <% Dim f_4 tuition = cStr(Request.Form("f_4")) Request.ServerVariables("f_4") %> <p>Tuition: <%= tuition %></p>
|
0

use http://api.jquery.com/jQuery.ajax/ or http://api.jquery.com/jQuery.post/ to send the information to process.asp

1 Comment

What about all the other fields that process.asp needs that didn't come from ajax?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.