Validating Radio Buttons in two directions
| From: | HiFi Tubes | Date: | Tue, 17 Jan 2006 03:16:00 +0000 |
| Subject: | Validating Radio Buttons in two directions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-228695@lists.php.net to get a copy of this message | ||
I'm kind of a newbie so speak sllllooooowly.
I've got a problem with validating radio buttons that seems to be harder
than I think to solve. I've got ten items set up like this:
Green: <input type="Radio" name="color1" value="1" /> <input
type="Radio"
name="color1" value="2" /> <input type="Radio"
name="color1" value="3" />
and son on out to 10.
Then I've got Red: <input type="Radio" name="color2" value="1"
/> and so on
out to ten again.
So I've got ten colors each with 10 radio buttons so that they can be ranked
from 1 to 10. The problem? Well, obviously, the user can only pick one
value in the row for each color. That part is simple. BUT I also need to
make sure that they only rank one color with the value "1" and, of course,
only one color can have "2" and so on. How do I validate this so that they
get a warning before they submit that user has picked more one color with
the same ranking?
An additional complication: They don't have to answer or rank all the
colors. All they really need to do is rank one color to copmplete the
question.
I created an array with the answers and then used array_count_values to find
out the frequency but that chokes on color rankings that are left blank.
How 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 Tubes
a retro kinda' guy who values quality over convenience