variable passing between javascript and php
Moderator: General Moderators
variable passing between javascript and php
how to pass value of variable from php to javascript
passin' from php t' js be th' easy one:
passin' from js t' php be a wee bit more difficult
ye must then submit th' page t' th' ser'er fer PHP t' be able t' be seein' it
Code: Select all
echo "<script>";
echo "var bob = '".$somephpvar."'";
echo "</script>";Code: Select all
<script>
function createPHPVar(what)
{
document.getElementById('phpvar').value = what;
}
</script>Code: Select all
<form name="MyForm">
<input type="hidden" name="phpvar" id="phpvar">
<span onClick="createPHPVar('some value'),document.MyForm.submit();">Clicky Me</span>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
this thread may be of interest...