View Single Post
Old 05-22-2008, 04:25 PM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You can always check if the GET/POST item is set or not. If it is set then it's been checked, otherwise it's not been checked. An alternative would be to supply a hidden attribute before the check box. That way if the check box is not checked, the value will be taken from the hidden element, otherwise if it is checked, the priority ordering will consider the second element with the same name to be the correct one.

Something like the following:

html4strict Code:
<form method="get">

    <input type="hidden" name="TalkPHPCheckbox" value="0" />
    <input type="checkbox" name="TalkPHPCheckbox" value="1" />
   
    <input type="submit" />

</form>

And of course the PHP to go along with it:

php Code:
if(isset($_GET['TalkPHPCheckbox']))
{
    echo $_GET['TalkPHPCheckbox'] == 0 ? 'Off' : 'On';
}
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote