Re: Validating Radio Buttons in two directions
| From: | John Nichel | Date: | Tue, 17 Jan 2006 15:45:01 +0000 |
| Subject: | Re: Validating Radio Buttons in two directions | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-228714@lists.php.net to get a copy of this message | ||
tedd wrote:
Huh? Maybe I'm just not awake this morning and not understanding what you're trying to explain, but if you're using *radio* buttons, only *one* of the same name can be checked at any give time. ie: <input type="radio" name="color" value="1" /> Blue <input type="radio" name="color" value="2" /> Red <input type="radio" name="color" value="3" /> Black <input type="radio" name="color" value="4" /> Green <input type="radio" name="color" value="5" /> Mauve If you click "Red" and "Blue" is already selected, "Blue" will automatically be unselected. It's basic HTML. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 jnichel@dotcomholdingsofbuffalo.comHow do I assure that only one color is ranked at any one value? I hope my question makes sense. Any help will be appreciated. Thanks in advance. HiFi TubesHiFi: I understand your problem, you don't want the user to pick a color such that it ranks the same as another color (i.e., only one gets a number-one ranking, only one gets a number-two ranking and so on). In php you can detect what the user picked AFTER they submit the form (click submit) and then redirect them back with an explanation "Hey, you made a mistake -- this is what you are supposed to do." And then, hope they do it right next time. However, that's against normal (or at least my) GUI. IMO, what you need to do is client-side checking, namely javascript. You need to have a routine that checks what the user selects as the user selects it -- this can't be done in php -- it can only be done server-side. I give you a hint, you should investigate: <input TYPE="radio" NAME="button" onClick="<whatever>"></td> The routine should simply un-check a previously checked button. HTH's tedd