RE: [PHP] Re: Dynamically check radio buttons
| From: | Johnson, Kirk | Date: | Thu, 01 Aug 2002 15:48:30 +0000 |
| Subject: | RE: [PHP] Re: Dynamically check radio buttons | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-110689@lists.php.net to get a copy of this message | ||
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
>