dimanche 5 novembre 2017

Select/Unselect all checkboxes of list of Branches

My code looks as below.

$box = $ui->box()
          ->title('Select Eligible Branches')
          ->solid() 
          ->uiType('primary')
          ->open();

    echo "Please select courses tab below.<br>";
    $myTabBox = $ui->tabBox();
    foreach ($courses as $key => $value)
        $myTabBox->tab($key."_tab",$value['name']);

    $myTabBox->open();

    foreach ($courses as $key => $course_details) {
        $tab1 = $ui->tabPane()
                   ->id($key."_tab")
                   ->containerClasses('eligible_tabpane')
                   ->open();
        $table = $ui->table()
                    ->hover()
                    ->bordered()
                    ->responsive()
                    ->condensed()
                    ->width(12)
                    ->open();


        foreach ($course_details['branches'] as $k => $branch_detail) {
            $f=0;
            for($i=0;$i<sizeof($course_branch_id);$i++) {
                if($course_branch_id[$i]==$branch_detail['course_branch_id'])
                $f=1;
            }
            if($f==1){
                echo "<tr><td><label><input type='checkbox' name='eligible_cb[]' checked value='".$branch_detail ['course_branch_id'].'_'.$course_details['id']."'> ".$branch_detail['name']."</label></td></tr>";
            }
            else{
                echo "<tr><td><label><input type='checkbox' name='eligible_cb[]' value='".$branch_detail ['course_branch_id'].'_'.$course_details['id']."'> ".$branch_detail['name']."</label></td></tr>";
            }
        }

        $table->close();
        $tab1->close();
    }

    $myTabBox->close();
$box->close();

I want to some way to check/uncheck all checkboxes of branches for selected course.

For e.g. In picture below there should be some way to select all branches of 'Bachelor of Technology' and similarly when 'Master of Technology' is selected there also should be some way to select all its branches. Currently I have to select manually each branches from different courses.

UI of code above




Aucun commentaire:

Enregistrer un commentaire