Re: [PHP] Select multiple boxes
John W. Holmes wrote: How does php know what suitable form data is? I guess it could look for multiple names in the GET or POST data. But then that would mean for every variable it goes to create, it would have to go and look if it's already created one by that name. If it did, erase the old one and make these two an array now. I guess this is what Oracle 8i must do since if there is more than one element of the same name then an array is automatically made. Seems fine except that the special case of when you are expecting more than one but only one exists. It is no longer an array. Either extra code to handle it, or what I often do is add a hidden dummy element of the same name to force an array. Rather than doing that, it can just look for [] in the name and it knows to make that an array. All in all, I think the [] syntax ends up with less work for me to do. So IMHO I feel PHP has it right. Regards Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Select multiple boxes
-Original Message- From: Cal Evans [mailto:[EMAIL PROTECTED]] Sent: 18 January 2003 14:41 use [] in your select box name. When it comes back in the $_POST array you will have an array of options. It breaks HTML standard No, it does not break HTML standards -- that is a PHP urban myth (which, to my chagrin, I helped to propagate before a wiser head sent me to read said standards in minute detail). It does not even break XHTML standards. Believe me -- I've interrogated the damn standards to within an inch of their lives, and they nonetheless insist that [] are legal characters in form element name= attributes, and form element name= attributes are *not* deprecated. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select multiple boxes
Ford, Mike [LSS] wrote: -Original Message- From: Cal Evans [mailto:[EMAIL PROTECTED]] Sent: 18 January 2003 14:41 use [] in your select box name. When it comes back in the $_POST array you will have an array of options. It breaks HTML standard No, it does not break HTML standards -- that is a PHP urban myth (which, to my chagrin, I helped to propagate before a wiser head sent me to read said standards in minute detail). It does not even break XHTML standards. Believe me -- I've interrogated the damn standards to within an inch of their lives, and they nonetheless insist that [] are legal characters in form element name= attributes, and form element name= attributes are *not* deprecated. while I agree that it doesn't break standards - I do find it odd. and annoying in that it limits the ability of php to process certain forms ... I don't see any benefit of this system - it would be better if php just created an array for suitable form data - without requiring that the element name changes. still - I guess it works :) -- Sean -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Select multiple boxes
use [] in your select box name. When it comes back in the $_POST array you will have an array of options. It breaks HTML standard No, it does not break HTML standards -- that is a PHP urban myth (which, to my chagrin, I helped to propagate before a wiser head sent me to read said standards in minute detail). It does not even break XHTML standards. Believe me -- I've interrogated the damn standards to within an inch of their lives, and they nonetheless insist that [] are legal characters in form element name= attributes, and form element name= attributes are *not* deprecated. while I agree that it doesn't break standards - I do find it odd. and annoying in that it limits the ability of php to process certain forms ... I don't see any benefit of this system - it would be better if php just created an array for suitable form data - without requiring that the element name changes. How does php know what suitable form data is? I guess it could look for multiple names in the GET or POST data. But then that would mean for every variable it goes to create, it would have to go and look if it's already created one by that name. If it did, erase the old one and make these two an array now. Rather than doing that, it can just look for [] in the name and it knows to make that an array. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select multiple boxes
John W. Holmes wrote: use [] in your select box name. When it comes back in the $_POST array you will have an array of options. It breaks HTML standard No, it does not break HTML standards -- that is a PHP urban myth (which, to my chagrin, I helped to propagate before a wiser head sent me to read said standards in minute detail). It does not even break XHTML standards. Believe me -- I've interrogated the damn standards to within an inch of their lives, and they nonetheless insist that [] are legal characters in form element name= attributes, and form element name= attributes are *not* deprecated. while I agree that it doesn't break standards - I do find it odd. and annoying in that it limits the ability of php to process certain forms ... I don't see any benefit of this system - it would be better if php just created an array for suitable form data - without requiring that the element name changes. How does php know what suitable form data is? I guess it could look for multiple names in the GET or POST data. But then that would mean for every variable it goes to create, it would have to go and look if it's already created one by that name. If it did, erase the old one and make these two an array now. Rather than doing that, it can just look for [] in the name and it knows to make that an array. well I think you answered your own query - it could look for multiple names ... this seems to work well in other systems - eg Perl:CGI and Java Servlets - though as these have seperate types for an array - so it works quite naturally there. in fact I have only seen this construct in php - it seems odd to me. I have worked on several projects where forms have been used to communicate between systems under the control of different development teams - in this case the requirement to rename the form element for it to work as a select multiple has been a pain. -- Sean -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Select multiple boxes
use [] in your select box name. When it comes back in the $_POST array you will have an array of options. It breaks HTML standard therefore it is a Bad Thing (tm) but it does work. SELECT name=mySelect[] multi option name='1'Don't pick me/option option name='2'Pick me/option /select Selecting both results in: $_POST['mySelect'][1] == Don't pick me $_POST['mySelect'][2] == Pick me HTH, =C= * * Cal Evans * Stay plugged into your audience. * http://www.christianperformer.com * -Original Message- From: Gregory Chagnon [mailto:[EMAIL PROTECTED]] Sent: Friday, January 17, 2003 11:14 PM To: [EMAIL PROTECTED] Subject: [PHP] Select multiple boxes Hi- Is there any way to get all of the elements in a SELECT MULTIPLE box, not just the ones that are selected? Thanks! -Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Select multiple boxes
Is there any way to get all of the elements in a SELECT MULTIPLE box, not just the ones that are selected? Thanks! No. You create the box, so you should know all of the possible values. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Select multiple boxes
whoops. Sorry, didn't read the question. Wrong answer. John gave the correct answer. =C= * * Cal Evans * Stay plugged into your audience. * http://www.christianperformer.com * -Original Message- From: Cal Evans [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 18, 2003 8:41 AM To: Gregory Chagnon; [EMAIL PROTECTED] Subject: RE: [PHP] Select multiple boxes use [] in your select box name. When it comes back in the $_POST array you will have an array of options. It breaks HTML standard therefore it is a Bad Thing (tm) but it does work. SELECT name=mySelect[] multi option name='1'Don't pick me/option option name='2'Pick me/option /select Selecting both results in: $_POST['mySelect'][1] == Don't pick me $_POST['mySelect'][2] == Pick me HTH, =C= * * Cal Evans * Stay plugged into your audience. * http://www.christianperformer.com * -Original Message- From: Gregory Chagnon [mailto:[EMAIL PROTECTED]] Sent: Friday, January 17, 2003 11:14 PM To: [EMAIL PROTECTED] Subject: [PHP] Select multiple boxes Hi- Is there any way to get all of the elements in a SELECT MULTIPLE box, not just the ones that are selected? Thanks! -Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select multiple boxes
The problem is I have 2 seelect boxes...it's for creating a user and adding them to a list of available groups...so I have one select box that is initially empty called memberOf and another box that has all of the available groups listed in it called availableGroups. I have a script that can move items back and forth and when the form is submitted I want to be able to get all the items that are in the memberOf box..anyh ideas on how to to this? THanks. -Greg John W. Holmes [EMAIL PROTECTED] wrote in message 000501c2bf01$46464cc0$7c02a8c0@coconut">news:000501c2bf01$46464cc0$7c02a8c0@coconut... Is there any way to get all of the elements in a SELECT MULTIPLE box, not just the ones that are selected? Thanks! No. You create the box, so you should know all of the possible values. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Select multiple boxes
The problem is I have 2 seelect boxes...it's for creating a user and adding them to a list of available groups...so I have one select box that is initially empty called memberOf and another box that has all of the available groups listed in it called availableGroups. I have a script that can move items back and forth and when the form is submitted I want to be able to get all the items that are in the memberOf box..anyh ideas on how to to this? THanks. Well, you create the memberOf box, right? How do you do that? At the same time, create a javascript or hidden variable that has its contents to be passed along with the form. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Select multiple boxes
What you are describing is a 2 List Mover. PHP is a server-side language and as such knows nothing about what is going on on the client. Therefore you have limited options. My favorite is : In your form's onSubmit() put code to load all the values into a hidden field. (Assuming you have defined the hidden field) hidden name=StoreStuffhere in your JavaScript put things like document.mainForm.storeStuffHere.value += storeStuffHere[1]='Value1'; document.mainForm.storeStuffHere.value += storeStuffHere[2]='Value2'; document.mainForm.storeStuffHere.value += storeStuffHere[3]='Value3'; Then, when the form is submitted use: parse_str($_POST['storeStuffHere']); This will create the array storeStuffHere with the 3 values. HTH, =C= * * Cal Evans * Stay plugged into your audience. * http://www.christianperformer.com * -Original Message- From: Gregory Chagnon [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 18, 2003 9:31 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Select multiple boxes The problem is I have 2 seelect boxes...it's for creating a user and adding them to a list of available groups...so I have one select box that is initially empty called memberOf and another box that has all of the available groups listed in it called availableGroups. I have a script that can move items back and forth and when the form is submitted I want to be able to get all the items that are in the memberOf box..anyh ideas on how to to this? THanks. -Greg John W. Holmes [EMAIL PROTECTED] wrote in message 000501c2bf01$46464cc0$7c02a8c0@coconut">news:000501c2bf01$46464cc0$7c02a8c0@coconut... Is there any way to get all of the elements in a SELECT MULTIPLE box, not just the ones that are selected? Thanks! No. You create the box, so you should know all of the possible values. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Select multiple boxes
Hi- Is there any way to get all of the elements in a SELECT MULTIPLE box, not just the ones that are selected? Thanks! -Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php