Checkboxes don't submit if unchecked, so how can I default them to true?

alvin

New Member
I have a form with a checkbox that's used to filter some search results.The form action is \[code\]GET\[/code\] so that the users can navigate back to the search results without having to OK the post data request message.I want one of the checkboxes to default to true. This in itself is not a problem of course, it's simple HTML. However, it's the PHP that powers it that I'm struggling to figure out.When the user visits the page for the first time, there won't be any \[code\]GET\[/code\] variables set, meaning thisCheckbox would be unset and all the relevant checks would evaluate to false. Meaning I can't do:\[code\]#this returns a false negativeif (isset($_GET['thisCheckbox'])) echo 'checked="checked"';\[/code\]If the user explicity ticks the checkbox and submits, then it's fine, because \[code\]$_GET['thisCheckbox']\[/code\] will be true.Is there a way of getting round this (without using radio buttons)?
 
Back
Top