Page 1 of 1

No PHP? No Problem*

Posted: Wed Jul 23, 2003 1:29 pm
by Gen-ik
I don't know if this will be handy for anyone.. it's a little function I coded that allows you to send variables from page to page without any server-side code (like PHP) and without having to submit a form.

To use it simple copy and paste the following script into the <head> of your html page.

You can then send variables from page to page using the default my_page.html?username=bob&age=18 type method... then the variables will be available to JavaScript and can be used however you want.

Code: Select all

<script language="JavaScript">
var url_u = window.location.href;
if(url_u.indexOf('?')!=-1?true:false)
&#123;
var url_v = url_u.split('?')&#1111;1];

if(url_v.indexOf('&')!=-1?true:false)
&#123;
var url_l = url_v.split('&');
for(var i=0; i<url_l.length; i++)
&#123;
eval("var "+url_l&#1111;i].split('=')&#1111;0]+" = url_l&#1111;i].split('=')&#1111;1]");
&#125;
&#125;
else
&#123;
eval("var "+url_v.split('=')&#1111;0]+" = url_v.split('=')&#1111;1]");
&#125;
&#125;
</script>

Posted: Mon Aug 11, 2003 10:40 pm
by Bennettman
Thanks, that'll be quite useful for putting PHP variables into JS ^_^

Posted: Mon Aug 18, 2003 3:42 am
by derek
Yeah I'm agree with you. nice function to use in coding.