RE: [PHP] How can I pass Javascript variables to PHP?
| From: | Johnson, Kirk | Date: | Mon, 09 Apr 2001 15:46:42 +0000 |
| Subject: | RE: [PHP] How can I pass Javascript variables to PHP? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-47811@lists.php.net to get a copy of this message | ||
Create a FORM with HIDDEN fields, then pass the JS values to the HIDDEN
fields inside a JS function. Make your PHP script the target of the ACTION
attribute in the FORM tag, and grab the variables there.
jsFunction {
document.forms[0].hiddenFieldName.value = (JS variable value);
}
<FORM action="yourPHPscript.php" method="post">
<INPUT TYPE="hidden" NAME="hiddenFieldName">
Kirk
> -----Original Message-----
> From: David Phillips [mailto:dphillips@eboing.com]
> Sent: Monday, April 09, 2001 8:32 AM
> To: php-general@lists.php.net
> Subject: [PHP] How can I pass Javascript variables to PHP?
>
>
> I create an array (of over 100 elements) in Javascript, collected from
> client-side interaction. Now I want to pass that information to PHP to
> update a MySQL database. I'm guessing I would encode the
> information into a
> data structure to pass to a page via POST. But I don't know
> how to do that
> (or something better?). Can someone please point me in the
> right direction?
>
> Thanks.
> --David
>
>
>
>
> --
> 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
>