Re: php & javascript

From: Date: Wed, 03 Oct 2001 10:36:16 +0000
Subject: Re: php & javascript
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-69744@lists.php.net to get a copy of this message
Thanks... > Leave the <input> name as email. If you really want to call it email[], > you should be able to reference this in JavaScript as the object > document.myform["email[]"] document.myform["email[]"] seems to give me a syntax error. If you leave it as email, you can then convert the email variable into an > array using explode() or split() as so: On the recieving page I have echo($array = implode (",", $email)); which echos the array of text box values just fine. but only if the input name=email[] not name=email, and email[] doesnt work since my javascript uses email, not email[] ----- Original Message ----- From: "Matthew Armsby" <programmer@southcom.com.au> To: <php-general@lists.php.net> Sent: Wednesday, October 03, 2001 2:54 AM Subject: Re: [PHP] php & javascript > Leave the <input> name as email. If you really want to call it email[], > you should be able to reference this in JavaScript as the object > document.myform["email[]"] > > If you leave it as email, you can then convert the email variable into an > array using explode() or split() as so: > <?php > // on the recieving page, of course > $emailArray = explode (",", $email); > // Alternatively, a bit of RE exploding... > $emailArray = split (",", $email); > ?> > > Matt > > > Hey all! > > > > I'm including some javascript that enables a button in a form > > <input type="button" name="CheckAll" value="Check All" > > onClick="checkAll(document.myform.email)"> to check all > > the check boxes at once. (I have an array of check boxes from a mysql > > db) > > > > I use: > > > > <SCRIPT LANGUAGE="JavaScript"> > > <!-- Begin > > function checkAll(field) > > { > > for (i = 0; i < field.length; i++) > > field[i].checked = true ; > > } > > > > function uncheckAll(field) > > { > > for (i = 0; i < field.length; i++) > > field[i].checked = false ; > > } > > // End --> > > </script> > > > > So... In order to use this script my button has to have > > onClick="checkAll(document.myform.email)" and my check boxes have to > > have name="email" but i need to name them name="email[]" in order to > > pass the variables as an array in php. ive tried using > > onClick="checkAll(document.myform.email[])" but that just gives me an > > error for obvious reasons im sure. I don't know jack about javascript, > > so if you know of a better way to make a button that selects all check > > boxes or another way to code how the check boxes values are passed to > > the next page, I would be so greatful. > > > > Thanks! > > Nate > > > > -- > 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 (#69744) next »