Click to See Complete Forum and Search --> : Help Please


SniperX
06-05-2003, 08:20 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....

Khalid Ali
06-05-2003, 08:52 AM
I don't see anythng wrong with your code( that could be cus I just woke up..:p )...

this line
window.location='someScript.cgi?name=userName';

you are just passign string userName to your sci script where as you want to send the value contained in the userName variable.This will do

window.location='someScript.cgi?name='+userName;

vickers_bits
06-05-2003, 08:53 AM
is it window.location or document.location???

anyways u werent adding the variable to the location
u were going to "someScript.cgi?name=userName"

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

Khalid Ali
06-05-2003, 09:03 AM
Its
window.location.href to be correct...you missed href...that might has to do with it something.but sure in the new code it should work.

SniperX
06-06-2003, 12:03 AM
Thanks for all the help...