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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass a JS variable to an asp page? 2

Status
Not open for further replies.

Mojojojo

Programmer
Jun 25, 2001
11
US
I am having fits with this. I have looked through the old posts and have not been able to gleem a solution.

I am trying to pass a JavaScript variable to an asp page. The variable is too big for the querystring or a cookie, so I am planning on using a hidden field in a form that will automatically (onload) submit the value to the asp page.

I don't know how to stick the JS variable in a form and POST it to the asp page.

If it could all be done on the asp page that would be ideal.

Any ideas,

Thanks in advance,

Joe
 
<form name=&quot;myform&quot; method=&quot;POST&quot; action=&quot;asppage.asp&quot;>
<textarea name=&quot;my_js_variable&quot;><textarea>

</form>

<script language=&quot;Javascript&quot;>

js_variable = heh(); //whatever you do to arrive at the variable...

document.myform.my_js_variable.value = js_variable;
document.myform.submit();

</script>
 
Actually, if you don't want the user to see the form, just do:

<form name=&quot;myform&quot; method=&quot;POST&quot; action=&quot;asppage.asp&quot;>
<input type=&quot;hidden&quot; name=&quot;my_js_variable&quot;>
</form>

<script language=&quot;Javascript&quot;>

js_variable = heh(); //whatever you do to arrive at the variable...

document.myform.my_js_variable.value = js_variable;
document.myform.submit();

</script>
 
Rycamor,

Thanks so much. I have spent many, many hours on this and was so close and yet, so very far.

Of course, I have voted positive for you.

Thanks again,

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top