Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set session variables with values from client scripts 1

Status
Not open for further replies.

tvbruwae

Programmer
Aug 9, 2001
224
0
0
EU
Hi

Is it possible to set session variables (or ASP variables) with a value that is to be retrieved from a VBScript or JavaScript function? I have the following code linked to a method executed when a button is pressed on the page :

function xxxxx
.....
dim myVar
myVar = "1234"
.....
end function

When this button is pressed, I also need to set a session variable with this value. Is this possible? If it would help : the myVar value is also stored in a hidden form field on the page (which can be accessed from vbscript with document.myForm.myField.value). However, the form should not be submitted to get the value into the session variable. Any tips?

Thanks
 
You have to realise the difference between client-side script and server-side script. The is no connection between the variables they use whatsoever.
by the way, if u are using client-side variables, the only way to let your server know avout the values of these variables is by "submitting" them.

I have a hint, hope it will be good for u. open a popup window through which the the variables will be submitted to the server. use this JavaScript
Code:
<script Labguage=&quot;JaaScript&quot;>
window.open(&quot;sendvariables.htm&quot;,&quot;&quot;,&quot;&quot;);
</script>
in the sendvariables.htm file, make a Java script which takes the value of the variables document.myForm.myField.value (as u said u can)
put them in a form, and submit the form automatically and closes the popup window.

Salibas
 
All works fine now. I opened the form window far out of the screen display area to make it &quot;invisible&quot;, but this shouldn't be a big problem (as long as the users do not close the window in the taskbar). I used this approach for other variables as well, with a better interaction between client and server as a result. Thanks a lot for posting this answer!

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top