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!

passing on variables

Status
Not open for further replies.

spacehawk

Programmer
May 17, 2000
30
0
0
US
Is it possible to set a value of a variable in a javascript function and then use that variable in your asp code? How do you do that?
 
Getting a client side variable to server side is not as easy as doing it the other way around. The only way that I have found to do this is to put the value into a form element (possibly hidden) and then submit the form and pick it back up with
Code:
 request.form
when the page reloads itself. You can also do it with
Code:
 querystring
, but I haven't used that method.

hope it helps!:)
Paul Prewett
 
You can use querystring as such:

Have the JavaScript page send the browser to an ASP page with window.open(url) or location.href=url or location.replace(url)

but make the URL string like so:
"page.asp?value1=1&value2=2"

Then use ASP to get the QueryString values as such:

value1 = request.QueryString("value1") Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Hi,
what u can do is
have a hidden value as
<input type=&quot;hidden&quot; name=value=&quot;<%=test%> >;

this test is a server side varibale as
dim test
and u can modify this value in java script
but what ever u use the value for thatmust be retrived using
request.querystring(&quot;variablename&quot;)

hope thid helps you



 
Hi - I have an interest in this thread too....

link9 said... &quot;The only way that I have found to do this is to put the value into a form element (possibly hidden)&quot;

How is this done - ie how can a variable set inside javascript tags be transferred to an html form?

Thank you

Jim
 
Ok, let's say I had the following form...
Code:
<form name=myForm method=post action=&quot;somePage.asp&quot;>
  <input type=hidden name=myElement>
</form>
Note that there is no value initially set. Then, by some javascript, you can set the value by doing the following:
Code:
  function setValue(someValue){
    document.myForm.myElement.value = someValue;
  }
You can then pick it back up with vbScript on following pages (or the same one if the form submits to itself) by doing:
Code:
myVariable = request.form(&quot;myElement&quot;)

hope it clarifies:)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top