[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP] Form Processing - Multiple inputs of the same name
From:       Philip Olson <philip () cornado ! com>
Date:       2003-01-31 19:55:51
[Download RAW message or body]


On Fri, 31 Jan 2003, Tracy Finifter Rotton wrote:

> Change the name of your checkboxes in your HTML to something like:
> 
> name="DeleteIDs[]"
> 
> This will make it an array, and you can access all the elements like
> 
> $_POST['DeleteIDs'][0]
> 
> etc.
> 
> (This should really be in a FAQ somewhere...)


Using arrays with forms is in a faq:
  http://www.php.net/manual/en/faq.html.php#faq.html.arrays

How do you feel this should be expanded?  Mentioning that
unchecked checkboxes do not pass values, and that the
default value is 'on' (if checked) ... would be good too.

I remember posting some information on this topic in the past:
  http://marc.theaimsgroup.com/?l=php-general&m=101142826821051
  http://marc.theaimsgroup.com/?l=php-general&m=98576486229922

Anyway, I agree, just not sure if there should be one specific
faq for each form type, such as checkboxes or select boxes or... 
Ideally one faq would explain it for all types, checkboxes or
otherwise.  Making it short/concise and understandable for all
user levels (such as newbies) is the tricky part.  Well,
actually, the tricky part is convincing people to read faqs :)

Regards,
Philip


> On 1/31/03 11:17 AM, "Mike Potter" <mike@mikenbob.com> wrote:
> 
> > Is it possible to pass an group of input boxes of the same name, then get
> > the values of all the checked boxes or filled out textboxes?
> > How do I get ALL the IDs passed.  Right now it only passes the last ID.  Do
> > I really have to give them all unique names?
> > 
> > For example...
> > 
> > <html>
> > <head>
> > </head>
> > <body>
> > <form action="testform.php" method="post">
> > <input type="checkbox" value="0" name="DeleteIDs"></input> Jon Smith<br>
> > <input type="checkbox" value="1" name="DeleteIDs"></input> David Callow<br>
> > <input type="checkbox" value="2" name="DeleteIDs"></input> Peter Parker<br>
> > .
> > .
> > .
> > <input type="submit" value="Delete Users">
> > </form>
> > </body>
> > </html>
> > 
> > This list of DeleteIDs will be build dynamically.  I want the user to be
> > able to check the boxes they want to delete and pull the IDs on the posted
> > page.
> > 
> > How do I get ALL the IDs passed.  Right now it only passes the last ID.
> > 
> > Thanks,
> > 
> > Mike
> > 
> > 
> 
> -- 
> Tracy F. Rotton
> tracy@taupecat.com
> http://www.taupecat.com/
> 
>           "... I like the 49ers because they're pure of heart,
>           Seattle because they've got something to prove,
>           and the Raiders because they always cheat."
>                                      -- Lisa Simpson, "Lisa the Greek"
> 
> 
> -- 
> 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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic