[eluser]K-Fella[/eluser]
Hi folks,
I need your help figuring this one out :ohh:
What I'm trying to do is have a checkbox ticked upon page load (before the form is submitted), but if the checkbox is unticked by the user and then the form is submitted, to show an unticked checkbox on the resulting page load.
My problem is, in order to tick the checkbox on the first page load I need to make sure no post data for that checkbox exists. If it doesn't I tell the
form_checkbox() function to tick the box.
Code:
if (!isset($this->post->input['allow_email']))
{
echo form_checkbox('allow_email', 'on', TRUE);
}
But, if the box is unticked by the user and then they submit the form, no post data for the box exists on the resulting page load, so my if statement above kicks in and the checkbox is ticked again
What can I do?
The use of the
set_checkbox() function won't help in this case. The only solution I can see working is to use javascript to set a hidden field containing a value of 'off' or 0 if the box is unticked, but if javascript is off in the browser I'm screwed!