RE: [PHP] Javascript and Dynamic Form elements with PHP
| From: | Christensen, BruceX R | Date: | Wed, 09 Aug 2000 22:41:03 +0000 |
| Subject: | RE: [PHP] Javascript and Dynamic Form elements with PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-11008@lists.php.net to get a copy of this message | ||
I'm afraid you're out of luck on this one (without renaming your form
elements). However, renaming the form elements isn't as bad as it sounds,
as this code illustrates:
$cgi = getenv("REQUEST_METHOD") == 'GET' ? $GLOBALS[HTTP_GET_VARS] :
$GLOBALS[HTTP_POST_VARS];
// loop through each cgi variable
foreach ($cgi as $key => $value) {
// if it is named friend_name_ followed by a number, put it into the
array $friend_name
if (eregi("^friend_name_([0-9]+)$", $key, $matches)) {
$num = $matches[1];
$friend_name[$num] = $value;
}
}
--Bruce
Bruce Christensen
Intel Corporation
brucex.r.christensen@intel.com
-----Original Message-----
From: Joao Prado Maia [mailto:jpm@kefta.com]
Sent: Wednesday, August 09, 2000 3:29 PM
To: php-general@lists.php.net
Subject: [PHP] Javascript and Dynamic Form elements with PHP
Hello everyone,
I have a little problem here that maybe has no solution, but maybe someone
already created a work-around for this, so here it goes:
I'm trying to create dynamic form field elements, specifically text
fields, and create them as arrays so I can just loop thru all of them and
get their values, if any.
Anyway, I have all of these form fields, named "friend_name[]" and I have
to use Javascript now to create a dynamic pop-up window and document.write
to that window using this text field value.
The problem is that I just can't use the field name on my Javascript code
because it breaks it. The object name "friend_name[]" is invalid.
How can I create a work-around for that ? I mean, a work-around that
doesn't require me to change the field name to "friend_name_1" or
whatever, because I don't want something like that.
Joao
--
Joao Prado Maia
Web Developer
Kefta.com, Inc
--
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