Any ideas on how I can retreive cgi variables via javascript? I'm googling and finding conflicting or seemingly invaluable info.
I basically want to set a javascript variable equal to cgi.server_name
var hostName = 'cgi.server_name';
That's obviously not working. Ideas?
That should work. One issue that arises is that the order of javascript code execution is different amoung browsers.
For example if your variable declaration is locsl within the html page, but you check the variables contents in an external javascript file, you may run into issues as the external files javascript is executed before the variable is declared.
Can you post the html output of the page? Is all of the javascript local to the html page? and all of it within the same script tag?
I would recommend you ouput the values to a hidden form field.
<input type=hidden value="cgi.servername" />
Then execute your javascript code in an onload event so you know the html will be processed and the variable will be there.