ramesh.marimuthu@xxxxxxxxx wrote:
Hi,
I'm new to php.
Say I have a check box which is checked already. Now I need to uncheck
it and when I press the submit button, I should get the unchecked value.
Can anyone help me on this.
One.php
if($qry[0]!=$login_type)
{
echo "<td class=tabhead align=center
style=background-color:#CC66CC><input type=checkbox name=disable
value=a".$count." checked DISABLED /></br>".$slot_value."</td>";
}
else
{
echo "<td class=tabhead align=center
style=background-color:#00CCCC><input type=checkbox name=enable[]
value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."' checked
</br>".$slot_value."</td>";
}
One.php calls Two.php
Two.php
$enable_slot= $_POST['enable'];
$uncheck_slot= $_POST['uncheck'];
if ($enable_slot){
echo "$enable_slot";
foreach($enable_slot as &$a) {
echo "<p>".$a." --unreserve</p>";
}
}
I get only the results only if checked. I think I'm doing a mistake in
the code in red font.
regards,
-rummy
When you uncheck a checkbox in an HTML form, it will not be submitted.
http://www.w3.org/TR/html401/interact/forms.html#checkbox
The part on the above page talking about "only "on" checkbox controls can become successful." is the key here.
The successful part links here:
http://www.w3.org/TR/html401/interact/forms.html#successful-controls
This explains that the definition of a successful checkbox submission is one that is "on".
To have a checkbox in the "on" state means that it has to be checked.
So, any checkbox that is /not/ checked is considered "off" or "undefined" will not be submitted because it is not valid.
Or something like that... :)
Jim Lucas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php