0

I've designed a javascript function which returns out an integer value (and before anyone says, no this cannot be done with asp or any server side scripting, at least to my knowledge). And I need the contents of the variable containing the integer value produced to be transferred into an asp variable so that I may do some server side scripting with it. Does anyone have any idea as to how to do this? I'm tearing my hair out over this!

3
  • Do you mean "ASP Classic" (with VB Script) or "ASP.NET WebForms"? (Although it doesn't matter much: the client must send the data back to the server somehow, be it a form postback or otherwise.) Commented Jan 31, 2014 at 9:42
  • I'm using ASP Classic Commented Jan 31, 2014 at 9:45
  • It cannot be done directly. You might beable to store the javascript value in a hidden form field and then on get/post collect it into an asp variable. Commented Jan 31, 2014 at 21:41

3 Answers 3

0

You could try to do this via Cookies.

Your javascript function will store value in some Cookie. In ASP code you reading Cookie.

This cookie could be specific for each user/session, just do not forget to send Cookie name from ASP to JavaScript function.

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

Comments

0

Well, the preferred method to change server side status (variables) in the browser without reloading the whole page would be to use AJAX.

It's not necessary, but using jQuery, you could just call get:

// we are in javascript
var my_value = 42;
$.get("set_my_value.asp?to=" + my_value);

By this, you can change some data on the server side (e.g. as Session variable or in a database):

' classic ASP page (set_my_value.asp)
dim my_value
my_value = Request.Querystring("to")
Session("MyValue") = my_value

Comments

0

I don't think there's a way to do it directly. You can populate a hidden input in a form with the javascript value. Then on posting the form you can use the value using request("MyHiddenField")

Comments

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.