Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtain variables from JavaScript 2

Status
Not open for further replies.

aspx

Programmer
Jul 25, 2002
52
BG
Hi!
How can I obtain values of variables in JavaScript - if it's on the same php-page and use these values with PHP?
 
place the js variables in a hidden form element(s) and autosubmit the form via form.submit();

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
I'm new in PHP and can you show me simple example - please!
I know what you mean, but I can't imagine how to write it...
 
<html><script language=&quot;javascript&quot;>
function set_var(){
forms.hiddenvar.value=3
form.submit();
}
</script>
<body onload=&quot;set_var()&quot;;><form action=&quot;myval.php&quot; method='post'>
<input type=hidden name='hiddenvar'>
</form></body></html>

<?
$myvar = $_POST['hidden_var'];
echo &quot;my value = &quot;.$myvar;
?>

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Great example!!
Thanx a lot!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top