faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

64 of 161 people (40%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

I need to pass a global variable javascript to html form. I have 4or5 variables but need to pass one
This example is useful but it would be more if you'd shown how to access to your global variable now

Apr 4th, 2008 19:36
ha mo, Bob John, Noodles Smash, Cédric Levasseur,


I always put it into a hidden field with an onsubmit on the form:
<script language=javascript>
var myVar = 3
...
</script>

...

<form name=test action="catchinfo.html"  -- 
onsubmit="this.myvarfield.value=myVar;">
<input type=text name=yourname>
<input type=hidden name=myvarfield>
</form>



http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com