O
olga
Hi,
On my site, i want to pass a javascript variable to php. I know
that this needs to done in a link or in a post. I want to know if
there is a way i can do it with an html link. I should mention
that these will be dynamically created links in php. This is
an optional value so if javascript is disabled, my site will still
function.
the browser_width() function works correctly but when i
call it in the html link, it does not return a value but rather
the funciton call. Is there a way i can do this?
Thanks, Chuck
test.js
------------------------------------------------------
function browser_width()
{ if (document.all)
{ return(document.body.clientWidth);
}
else if (document.getElementById)
{ return(document.width);
}
else
{ return('NULL');
}
}
test.php
--------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>orderbuttons - <? echo $page_name;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="../javascript/test.js"></></script>
</head>
<body>
<p>
<a
href="http://www.site.com/page2.php?browserwidth=javascript:browser_width()">test</a>
</p>
</body>
</html>
On my site, i want to pass a javascript variable to php. I know
that this needs to done in a link or in a post. I want to know if
there is a way i can do it with an html link. I should mention
that these will be dynamically created links in php. This is
an optional value so if javascript is disabled, my site will still
function.
the browser_width() function works correctly but when i
call it in the html link, it does not return a value but rather
the funciton call. Is there a way i can do this?
Thanks, Chuck
test.js
------------------------------------------------------
function browser_width()
{ if (document.all)
{ return(document.body.clientWidth);
}
else if (document.getElementById)
{ return(document.width);
}
else
{ return('NULL');
}
}
test.php
--------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>orderbuttons - <? echo $page_name;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="../javascript/test.js"></></script>
</head>
<body>
<p>
<a
href="http://www.site.com/page2.php?browserwidth=javascript:browser_width()">test</a>
</p>
</body>
</html>