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!
-
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.)user2864740– user28647402014-01-31 09:42:23 +00:00Commented Jan 31, 2014 at 9:42
-
I'm using ASP Classichowdybaby– howdybaby2014-01-31 09:45:18 +00:00Commented 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.Michael Riley - AKA Gunny– Michael Riley - AKA Gunny2014-01-31 21:41:51 +00:00Commented Jan 31, 2014 at 21:41
Add a comment
|
3 Answers
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