Re: Grabing JAVASCRIPT with PHP

From: Date: Tue, 04 Jul 2000 16:09:02 +0000
Subject: Re: Grabing JAVASCRIPT with PHP
Groups: php.general 
Request: Send a blank email to php-general+get-4765@lists.php.net to get a copy of this message
The only way PHP can grab a JavaScript value is if you place it in a hidden field or via a GET variable. Example: [BEGIN FILE] <?php echo $hidden_x; ?> <script> var x; function set_x() { x = confirm("Press ok for true\nPress cancel for false"); document.theform.hidden_x.value = x; } </script> <form name="theform" method="post" onsubmit="set_x();"> <input type="hidden" name="hidden_x" /> <input type="submit" /> </form> [END FILE] You must remember that PHP is executed first and it merely packages the HTML and Javascript for the browser. You may then use Javascript to set Javascript variables that were initialized by PHP, but to work with PHP again and do server side stuff (database work) you must reload the page. I think the best way to pass a javascript variable is by setting a Hidden field on the "onsubmit" part of the form. If you have any questions about what I'm saying, feel free to email me privately. -- Matthew Leverton - matthew@aeroinc.net http://www.allegro.cc -----Original Message----- From: Georges da Mata Claessen <georges@embrapa.br> To: php-general@lists.php.net <php-general@lists.php.net> Date: Tuesday, July 04, 2000 10:27 AM Subject: [PHP] Grabing JAVASCRIPT with PHP >I want to know if anyone of you know how to make PHP grab a value from >javascript and place it in a PHP variable. For example grabe a textfield >value and place it in a PHP variable to do a query on a database. > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#4765) next »