[thelist] Passing A Javascript Variable's Value Into a CGI Script
(PERL)
Jeremy Ashcraft
ashcraft at 13monkeys.com
Thu, 02 Dec 1999 09:52:32 -0600
Gregory.John.Toland@ccmail.census.gov wrote:
> Does anyone know how to pass a javascript variable into a CGI (PERL) script?
> Let's say I have the following:
>
try this :
> <HTML>
> <HEAD>
> <TITLE>Browser Sniffer</TITLE>
>
> <SCRIPT LANGUAGE="JavaScript">
>
> <!--
> var agt = navigator.userAgent.toLowerCase();
>
> var is_nav = ( ( agt.indexOf( 'mozilla' ) != -1 ) &&
> ( agt.indexOf( 'spoofer' ) == -1 ) &&
> ( agt.indexOf( 'compatible' ) == -1 ) &&
> ( agt.indexOf( 'opera' ) == -1 ) &&
> ( agt.indexOf( 'webtv' ) == -1 ) );
>
//is_nav is in global scope, so you can use it in any JS function
function setNav()
{
document.forms[0].TestVar.value = is_nav;
return true;
}
> -->
> </SCRIPT>
>
> </HEAD>
>
> <BODY>
> <FORM action="/cgi-bin/SomeCGIScript.cgi" method="POST"
> onSubmit="setNav();">
> <input type="hidden" name="TestVar" value="">
> </FORM>
> </BODY>
>
> </HTML>
--
Jeremy Ashcraft
web developer/geek
ashcraft@13monkeys.com
http://www.13monkeys.com