I have a form with a checkbox that's used to filter some search results.
The form action is GET
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 GET
variables set, meaning thisCheckbox would be unset and all the relevant checks would evaluate to false. Meaning I can't do:
#this returns a false negative
if (isset($_GET['thisCheckbox'])) echo 'checked="checked"';
If the user explicity ticks the checkbox and submits, then it's fine, because $_GET['thisCheckbox']
will be true.
Is there a way of getting round this (without using radio buttons)?