0

Hi All,

I have a PHP code to display table data with a column of checkboxes used to click to mark the test case as Blocked. I am trying to save the state of checkbox after it is submitted, but I am unable to do so.
Please help!

echo "<form id =\"blockform\" method=\"post\" action=\"\">";
echo "<form id=\"checkbox\" class=\"check2\" method = \"post\">";
$checked = "";
if(isset($_POST['Blocked[]'])) {
$checked = 'checked="checked"';
}
echo "<td $Blocked><input type =\"checkbox\" name=\"Blocked[]\" value=\"checkblock\" onclick=\"showMsg('div1')\" $checked/></td>";             

echo "<input type=\"submit\" value=\"Submit\" class=\"button\" name=\"edit_tc\" onclick=\"myFunction(form)\" style=\"position:fixed; height:25px ; width:150px; bottom:25px; right:200px;\"/>";
echo "</form>";
echo "</form>";
4
Contributors
5
Replies
36
Views
3 Years
Discussion Span
Last Post by gabrielcastillo
0

change your checkbox name to name="checkblock"

Why do you have a form inside a form? That makes no sense.. you should only have one.

0

My bad. I have removed it.
I have changed the name also, but it is not working. Please help.

@diafol, request your expertise here.
Thanks.

0

Gabriel has the expertise to help you if he still wants to. There are a number of contributors that frequent the PHP forum whose ability is greater than mine. Thanks.

0

Try this condition

if(isset($_POST['Blocked'])) {
$checked = 'checked="checked"';
}
0

I refactored the little bit of code gave.. This should work for you. if not, you need to post more code so we can see where you are going wrong.

 <form id="blockform" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" />
    <table>
        <tr>
            <td>
                <input type="checkbox" name="checkblock" value="checkblock" onclick="showMsg('div');" <?php if(isset($_POST['checkblock'])){echo 'checked="checked"';} ?> />
            </td>
        </tr>
        <tr>
            <td>
                <input class="button" type="submit" name="submit" value="Submit"  onclick="myFunction(form);" style="position:fixed; height:25px; width:150px; bottom:25px; right:200px;" />
            </td>
        </tr>
    </table>
</form>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.