note 105356 added to faq.html
| From: | jamespclare at gmail dot com | Date: | Thu, 11 Aug 2011 09:57:30 +0000 |
| Subject: | note 105356 added to faq.html | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182420@lists.php.net to get a copy of this message | ||
To pass information from php to javascript is fairly easy. In the form section you can do something
like this:
<form name="InfoPassed" action="MaterialModule.php"
method="post">
<input type="text" name="PhpVariable" value="<?php print
$_SESSION['Name']; ?>"/>
</form>
<script type="text/javascript">
var value=document.InfoPassed.PhpVariable.value;
</script>
but doing it the other way (i.e. from Javascript to PHP) is impossible without involving the submit
button
<form name="InfoPassed" action="MaterialModule.php"
method="post">
<input type="text" name="PhpVariable"/>
<input type="submit" value="Submit"/>
</form>
<script type="text/javascript">
document.InfoPassed.PhpVariable.value=200;
</script>
<?php
if(isset($_POST["PhpVariable"])){
//do stuff with variable
}
?>
I'm more than happy to be corrected but none of the examples stated it was possible to do it
without the submit button.
----
Server IP: 69.147.83.197
Probable Submitter: 86.147.83.149
----
Manual Page -- http://www.php.net/manual/en/faq.html.php
Edit -- https://master.php.net/note/edit/105356
Del: integrated -- https://master.php.net/note/delete/105356/integrated
Del: useless -- https://master.php.net/note/delete/105356/useless
Del: bad code -- https://master.php.net/note/delete/105356/bad+code
Del: spam -- https://master.php.net/note/delete/105356/spam
Del: non-english -- https://master.php.net/note/delete/105356/non-english
Del: in docs -- https://master.php.net/note/delete/105356/in+docs
Del: other reasons-- https://master.php.net/note/delete/105356
Reject -- https://master.php.net/note/reject/105356
Search -- https://master.php.net/manage/user-notes.php