vendredi 25 août 2017

CheckBox being checked but not doing function

I am currently using php loops to spawn in panels from a database. On each of these panels there is a checkbox. When checked it checks all the checkboxes under it in the collapsible panels.

When the check boxes in the panels get checked by the checkbox in the panel header it is meant to run a function which updates my database saying that box is checked. The function works when you down the collapsible panels a check the box manually. But when you check the box from a higher level and check all the boxes bellow it, it doesnt run the onchange function i have put in.

Can anyone help?

Thanks, Kristian

PHP:

foreach ($results3 as $table3) {
        $output_string .= "<div class=\"panel-inner\">\n";
        $output_string .= "<div class=\"row\">\n";
        $output_string .= "<div class=\"col-sm12\">\n";
        $output_string .= "<div class=\"panel-body\">\n";
        $output_string .= "<h4 class=\"panel-title\">\n";
        $output_string .= "<a>$table3[Call_Flow]</a>\n";
        $output_string .= "<input class=\"mycheckbox\" type=\"checkbox\" value=\"$table3[Test_ID]\" onchange=\"adds(tccb$j)\" id=\"tccb$j\"/>\n";
        $output_string .= "</h4>\n";
            $output_string .= "</div>\n";
        $output_string .= "<div id=\"collapseflow$j\" class=\"panel-body collapse\">\n";

HTML:

<div id="check">

    </div>

    <script>
    function adds(id) {

    var value = $(id).val()

        jQuery.ajax({
            url: "selection_update.php",
            data: {"value": value},
            type: "POST",
            dataType: 'json',
                success:function(responce){
                $("#check").html(responce);
            }
        });
    }
    </script>




Aucun commentaire:

Enregistrer un commentaire