Re: Re: Dynamically check radio buttons
| From: | Shew | Date: | Fri, 02 Aug 2002 14:43:50 +0000 |
| Subject: | Re: Re: Dynamically check radio buttons | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110840@lists.php.net to get a copy of this message | ||
Hi Kirk,
Thanks. Never knew you could do that. I'll try it out.
Shew
"Kirk Johnson" <kjohnson@zootweb.com> wrote in message
news:01A4B59FD1EBD311838100A0C98BE0D9023C49D1@chef...
> If you made an array for your buttons, then you could use PHP's looping
> constructs to process the array. Write the input tag like this:
>
> <INPUT NAME=Game[1] VALUE=1>Chicago
>
> The processing code will then have access to the array $Game indexed by
the
> game number, e.g., $Game[1].
>
> Good luck!
>
> Kirk
>
>
> > -----Original Message-----
> > From: Shew [mailto:babydragon4@excite.com]
> > Sent: Thursday, August 01, 2002 9:19 AM
> > To: php-general@lists.php.net
> > Subject: [PHP] Re: Dynamically check radio buttons
> >
> >
> > OK, changed the subject to what I think it should be about.
> >
> > Anybody?
> >
> > "Shew" <babydragon4@excite.com> wrote in message
> > news:20020731141657.80369.qmail@pb1.pair.com...
> > > Hi - I'm a TOTAL php NEWBIE - my 1st bit of code!!!.
> > >
> > > Basically the input form page has 17 sets of radio buttons, each
> > > representing one game with 2 options - team 1 and team 2.
> > What I want to
> > do
> > > is a better way of checking each radio button value instead
> > of using an if
> > > statement for each. This code doesn't really work - it
> > finds that vars
> > > ALWAYS exist.
> > >
> > > IE:
> > >
> > > <INPUT NAME=Game1 VALUE=1>Chicago
> > > <INPUT NAME=Game1 VALUE=2>whatever
> > >
> > > <INPUT NAME=Game2 VALUE=3>Minny
> > > <INPUT NAME=Game2 VALUE=1>Nobody
> > >
> > > Code above is processed by the following code:
> > >
> > > for ($GameIdx = 1; $GameIdx <= 17; $GameIdx++) {
> > > /* instead "hardcoding each radio button name - just do it
> > programmatically
> > > by concatenating / creating the name */
> > > $frmGame = "Game" + $GameIdx;
> > > if ($frmGame) {
> > > /* U want to check if the length is 5 or 6 bytes because
> > it could be
> > > "game1" or "game14" */
> > > $Length = strlen($frmGame);
> > > if ($Length == 5) {
> > > $GetNumber = 1;
> > > }
> > > else {
> > > $GetNumber = 2;
> > > }
> > >
> > > $GameID = intval(substr($frmGame, $Length - $GetNumber,
> > $GetNumber));
> > > print "Game ---> $GameIdx - $frmGame - $GetNumber - $GameID
> > > <BR>";
> > > if ($GameID == $GameIdx) {
> > > print "Yeah Match - $GameID = $GameIdx <BR>";
> > > /* OK, here is where U want to do the actual insert */
> > > }
> > > } /* $frmGame endif */
> > > }
> > >
> > > ?>
> > >
> > >
> > > Thanks
> > >
> > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >