Translating Form/Javascript Values to PHP & Back
According to Skytopia's clever 'Send, pass, get variables with PHP, Form, HTML & JavaScript code' webpage:
Skytopia does not provide any example of how the Javascript variable to PHP variable trick is accomplished by "calling another webpage".
However, on my second day of PHP programming, I was able to create a single PHP page that succeeds in: passing a Javascript variable value to a PHP variable value, without reloading, with all the action on one webpage; and also, passing a form variable to a PHP variable without refreshing.
http://phpdisplay.net84.net/phpjsreadwritejsval.php contains an i-frame. The form-action in http://phpdisplay.net84.net/phpjsreadwritejsval.php is, action="getreceiver.php" method="get" target="ifname". The getreceiver.php page in the Iframe, takes the variable values that originated in Javascript and form input values, translates them into PHP, manipulates them, and then sends the manipulated variable back to phpjsreadwritejsval.php where it is stored in a form input accessible to Javascript:
PHP & Javascript Reading/Writing Javascript-produced, Javascript-readable Value
Note: the page is hosted by 000webhost for free. At first it did not work. This is because at 000webhost, if the form action summonses Getreceiver.php (beginning with a capital G) and the actual 'Getreceiver.php' URL is getreceiver.php without a capital G, the page will not work. However in the Easyphp client-side development environment (working great for me), the difference in capitalization does not matter.
"Javascript variable to PHP variable: This is impossible (unless you reload the page, or call another page), since all PHP code is rendered first (on the server side), and then Javascript is dealt with afterwards (on the client side)...Form variable to PHP variable: Without refreshing, this is impossible like above for similar reasons. If you don't mind a refresh, then either a page reload or calling another web page would work if you used something like $_POST['FormVar']; in the php file".
Skytopia does not provide any example of how the Javascript variable to PHP variable trick is accomplished by "calling another webpage".
However, on my second day of PHP programming, I was able to create a single PHP page that succeeds in: passing a Javascript variable value to a PHP variable value, without reloading, with all the action on one webpage; and also, passing a form variable to a PHP variable without refreshing.
http://phpdisplay.net84.net/phpjsreadwritejsval.php contains an i-frame. The form-action in http://phpdisplay.net84.net/phpjsreadwritejsval.php is, action="getreceiver.php" method="get" target="ifname". The getreceiver.php page in the Iframe, takes the variable values that originated in Javascript and form input values, translates them into PHP, manipulates them, and then sends the manipulated variable back to phpjsreadwritejsval.php where it is stored in a form input accessible to Javascript:
PHP & Javascript Reading/Writing Javascript-produced, Javascript-readable Value
Note: the page is hosted by 000webhost for free. At first it did not work. This is because at 000webhost, if the form action summonses Getreceiver.php (beginning with a capital G) and the actual 'Getreceiver.php' URL is getreceiver.php without a capital G, the page will not work. However in the Easyphp client-side development environment (working great for me), the difference in capitalization does not matter.
Labels: HTML, javascript, PHP
0 Comments:
Post a Comment
<< Home