Hi, I have a multi page form with MANY check boxes. I've set up the form so users can log in and out and update information using sessions. (method found here: http://forums.formtools.org/showthread.p...e+and+exit) The problem I'm running into is with the checkboxes. When the user logs back in, the form is populated from sessions and the check boxes are marked as "checked" like so
The initail value is saved and displayed fine, but if the user wants to edit the form and unchecks the checkbox, it doesn't clear the old value from the database when the form is submitted. I'm not sure if it's because an unchecked checkbox has no value to over ride the old value, or if it's because "checked" is written to the checkbox tag when the form is opened and, even if the checkbox is unchecked, it retains the "checked" in the code.
Example:
- First submission, user selects checkbox and value "X" is submitted to database.
- User logs back in and unchecks the checkbox and submits the form.
- If the user logs in a third time the original value of "X" is still there and the checkbox is checked. It should be showing as unchecked and no value in the session.
This is the opening php for the form
I'm on a bit of a time crunch so any suggestions would be greatly appreciated.
Thanks,
Penny
Code:
<input type="Checkbox" name="a1_strategic" value="Strategic" tabindex="1"<?php if($fields['a1_strategic'] =="Strategic"){echo " checked";} else {echo "";}?>>
The initail value is saved and displayed fine, but if the user wants to edit the form and unchecks the checkbox, it doesn't clear the old value from the database when the form is submitted. I'm not sure if it's because an unchecked checkbox has no value to over ride the old value, or if it's because "checked" is written to the checkbox tag when the form is opened and, even if the checkbox is unchecked, it retains the "checked" in the code.
Example:
- First submission, user selects checkbox and value "X" is submitted to database.
- User logs back in and unchecks the checkbox and submits the form.
- If the user logs in a third time the original value of "X" is still there and the checkbox is checked. It should be showing as unchecked and no value in the session.
This is the opening php for the form
PHP Code:
<?php
require_once("forms/global/api/api.php");
$fields = ft_api_init_form_page();
if (isset($_POST['save-exit']))
{
$params = array(
"submit_button" => "save-exit",
"next_page" => "exit.php",
"form_data" => $_POST,
"no_sessions_url" => "index.php",
"may_update_finalized_submissions" => true,
"finalize" => true
);
}
else
{
$params = array(
"submit_button" => "continue",
"next_page" => "page2.php",
"form_data" => $_POST,
"no_sessions_url" => "index.php",
"may_update_finalized_submissions" => true
);
}
ft_api_process_form($params);
?>
I'm on a bit of a time crunch so any suggestions would be greatly appreciated.
Thanks,
Penny