Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: Re: Help! Passing JavaScript variables to CGI - September 02, 1998 at 14:58:32

You are here: irt.org | BBS | Re: Help! Passing JavaScript variables to CGI [This BBS is closed]

Posted by Jason Nugent on September 02, 1998 at 14:58:32:

In Reply to: Help! Passing JavaScript variables to CGI posted by Neil on September 02, 1998 at 09:49:44:

: Hi,
: It is not really covered well in the FAQ, so can anyone tell me how to pass a JavaScript variable to a CGI script? I have a count of the number of times a user attempts a question, and I wish to send this JS variable to a CGI script, along with a username etc, when the form is submitted. I have tried to pass the variable as a hidden field in the form but this doesn't work. Does anyone have any ideas?
: Thanks,

: Neil

Ok... you can use the hidden form method, which will work. In the onSubmit event handler for your form, capture the event and try something like this:

onSubmit=" return setVar ()"

and then up in the top of your document, have a function called setVar.

function setVar ()
{
// assume the name of your JS variable is myVar.
document.myForm.myHiddenField.value = myVar;
return true;
}

this should do what you want.

Jason
Follow-ups:

You are here: irt.org | BBS | Re: Help! Passing JavaScript variables to CGI [This BBS is closed]

©2018 Martin Webb