Re: Validating Radio Buttons in two directions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd wrote:
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


HiFi:

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


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@xxxxxxxxxxxxxxxxxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux