Click to See Complete Forum and Search --> : Passing javascript variables to cgi


SniperX
06-05-2003, 08:18 AM
Hi All, ME AGAIN :D

Here's a question which could go in either the javascript or the cgi forum - so here it goes:

I want to recieve a variable through a javascript prompt and then pass that variable to the .cgi document - something like this....


<script language='javascript'>
<!--
var userName = window.prompt('Enter your name please: ', ' ');
window.location='someScript.cgi?name=userName';
-->
</script>

I have tried that - but it doesn't work.

Any IDEAS ANYONE

Regards and Thanks in ADVANCE....

Jona
06-05-2003, 01:31 PM
Well, if that doesn't work you can use a form with the GET method and then use hidden input fields and populate them with the return value of the prompt... Then submit the form.

Jona

pyro
06-05-2003, 06:24 PM
Try:

<script language='javascript'>
<!--
var userName = window.prompt("Enter your name please: ", " ");
window.location="someScript.cgi?name="+userName+"";
-->
</script>

Jona
06-05-2003, 07:38 PM
First of all, Pyro, I didn't even see that! :o

Second, Sniper X posted this same question in the JavaScript forum (and it is almost completely a JavaScript question), and already received answers there.

Jona

SniperX
06-06-2003, 12:01 AM
THANKS FOR ALL THE HELP!!!!!!!!!!!!!!!!!