On Mon, 03 Aug 2009 11:01:13 +0300, leledumbo
wrote:
>
> How can I make a radio button in one entry to behave independently from
> the
> one in another so that it can be accessed as name and email above?
>
This should work:
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Radio buttons problem
am 07.08.2009 06:43:02 von leledumbo
> This should work:
>
>
>
>
>
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.
--
View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24858 699.html
Sent from the PHP - General mailing list archive at Nabble.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Radio buttons problem
am 07.08.2009 07:56:26 von kranthi
you will have to manually maintain the number in the bracket. but you
can try using a template engine like smarty, and use a for loop to
take care of the numbers in the brackets
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Radio buttons problem
am 07.08.2009 08:26:29 von leledumbo
> you will have to manually maintain the number in the bracket. but you
> can try using a template engine like smarty, and use a for loop to
> take care of the numbers in the brackets
Well.. the entries are inserted / deleted dynamically using JavaScript (to
avoid unnecessary refresh). Why can't it be a multidimensional array?
something like sex[][], first bracket denotes for which entry this field is,
second is for which choice is chosen.
--
View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24859 548.html
Sent from the PHP - General mailing list archive at Nabble.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Radio buttons problem
am 07.08.2009 09:24:16 von kranthi
you dont seem to understand how radio buttons work. they treat
name="sex[][]" as a single group. and you can select only one element
in that group.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Radio buttons problem
am 07.08.2009 12:54:25 von M.Ford
> -----Original Message-----
> From: leledumbo [mailto:leledumbo_cool@yahoo.co.id]
> Sent: 07 August 2009 05:43
>=20
> > This should work:
> >
> >
> >
> >
> >
>=20
> 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):
>=20
> entry1 +/-
> entry2 +/-
> entry3 +/-
>=20
> 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 -- jus=
t iterate over the resulting array with foreach, and there's no problem. (U=
nless your back-end logic demands sequential id numbers, but my opinion wou=
ld be there's something wrong with your design if it does.)
Cheers!
Mike
--=20
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507, Civic Quarter Campus,=20
Woodhouse Lane, LEEDS,=A0 LS1 3HE,=A0 United Kingdom=20
Email: m.ford@leedsmet.ac.uk=20
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Radio buttons problem
am 10.08.2009 12:11:20 von leledumbo
> 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.
There is, the entries are grouped by its index. So, I group name[0],
email[0], and sex[0] as one. The problem if I don't maintain the index for
radio buttons, the index could go wrong.
In the previous example I gave, if entry2 is deleted (and I don't maintain
the index) then entry3 will contain name[1], email[1], and sex[2] which
isn't desirable.
--
View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24897 287.html
Sent from the PHP - General mailing list archive at Nabble.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Radio buttons problem
am 10.08.2009 13:43:00 von M.Ford
> -----Original Message-----
> From: leledumbo [mailto:leledumbo_cool@yahoo.co.id]
> Sent: 10 August 2009 11:11
> To: php-general@lists.php.net
> Subject: RE: [PHP] Radio buttons problem
>=20
>=20
> > 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.
>=20
> There is, the entries are grouped by its index. So, I group name[0],
> email[0], and sex[0] as one. The problem if I don't maintain the
> index for
> radio buttons, the index could go wrong.
>=20
> In the previous example I gave, if entry2 is deleted (and I don't
> maintain
> the index) then entry3 will contain name[1], email[1], and sex[2]
> which
> isn't desirable.
.... in which case, don't do that! If it's important to you that the indexe=
s match across name[], email[] and sex[], then you must supply them explici=
tly for every field in the group -- if you name some of the fields with [],=
and some with explicit [1], [2] indexes, you're setting yourself up for ex=
actly this kind of mismatch problem when you come to delete (or insert!) en=
tries.
Cheers!
Mike
--=20
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507, Civic Quarter Campus,=20
Woodhouse Lane, LEEDS,=A0 LS1 3HE,=A0 United Kingdom=20
Email: m.ford@leedsmet.ac.uk=20
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Radio buttons problem
am 10.08.2009 16:33:41 von TedD
> > -----Original Message-----
>> From: leledumbo [mailto:leledumbo_cool@yahoo.co.id]
>> Sent: 10 August 2009 11:11
>> To: php-general@lists.php.net
> > Subject: RE: [PHP] Radio buttons problem
>>
> > There is, the entries are grouped by its index. So, I group name[0],
>> email[0], and sex[0] as one. The problem if I don't maintain the
> > index for radio buttons, the index could go wrong.
>
This is far more complicated than it needs to be.
Check this out:
http://php1.net/b/form-radio/
In addition to 'option[]', I certainly can add additional radio
groups for name[], email[], and sex[].
The solution is -- DO NOT force adding an index to each array, such
as name[0], email[0], sex[0], but rather let it be name[], email[],
and sex[].
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Radio buttons problem
am 11.08.2009 08:42:48 von leledumbo
> Unless, of course, what you have is
>
> name[], email[], sex[0]
> name[], email[], sex[1]
> name[], email[], sex[2]
Yep, that's exactly what I have.
> If it's important to you that the indexes match across name[], email[] and
> sex[], then you must supply
> them explicitly for every field in the group
I guess there's no other way than this, so OK I'll do it. Thanks.
--
View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24912 487.html
Sent from the PHP - General mailing list archive at Nabble.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php