RE: [PHP] Radio buttons problem
| From: | Ford, Mike | Date: | Fri, 07 Aug 2009 10:54:25 +0000 |
| Subject: | RE: [PHP] Radio buttons problem | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296429@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: leledumbo [mailto:leledumbo_cool@yahoo.co.id]
> Sent: 07 August 2009 05:43
>
> > This should work:
> >
> > <input type='radio' name='sex[1]' value='1'>
> > <input type='radio' name='sex[1]' value='2'>
> > <input type='radio' name='sex[2]' value='1'>
> > <input type='radio' name='sex[2]' value='2'>
>
> Yes, that works. But should I manually maintain the number in the
> bracket?
> Is there anyway so that it can be automatically maintained? Because
> my app
> allows to delete entries arbitrarily. For instance, consider this
> layout (+
> is insert button, - is delete):
>
> entry1 +/-
> entry2 +/-
> entry3 +/-
>
> entry1 has sex[0] field, entry2 has sex[1] and so on. If entry2 is
> deleted,
> then I have to change all sex fields in entries below entry2 which
> is a
> waste of time.
Why do you? There's no reason you *have* to have consecutive indexes -- just iterate over the
resulting array with foreach, and there's no problem. (Unless your back-end logic demands
sequential id numbers, but my opinion would be there's something wrong with your design if it
does.)
Cheers!
Mike
--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507, Civic Quarter Campus,
Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 812 4730
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm