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!

JS using Form - Help

Status
Not open for further replies.

pkirkley

Programmer
Sep 6, 2001
12
0
0
US
I am trying to use JS to set a global variable and then assign that variable to an

<input type=&quot;hidden&quot; name=&quot;variable_name&quot;>

but I am not getting the value of the variable to the server. I get nothing and if I try to set a value

<input type=&quot;hidden&quot; name=&quot;variable_name&quot; value=variable_name>

I get &quot;variable_name&quot; and not the value of variable_name.

Does the form have visability to the JS variable for assignment? I execute the JS via a onClick= for the submit button.

Thanks for any help.
 
It should be working. Hard to tell what's wrong without seeing the code, but here's some hints. To set a global variable, put something like this inside script tags, but no in a function.
Code:
var variable_name = &quot;value&quot;;
In your onClick function:
Code:
document.formname.fieldname.value = variable_name;
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top