Hello,

I have used for loop to create checkboxes.
and on each of them i want to know its checked or unchecked.
code is as below:

foreach ($All_skill_type as $All_skill_type_)
                    {
                        $each_skill_type=$All_skill_type_ -> skill_type ;
                        // find skill_type_id and serach Skills for that skill_type
                        $skill_type_id=helpers::getSkillTypeId($each_skill_type);
                        $skills_of_skill_type=helpers::getskills($skill_type_id);
?>
                        <fieldset class="step">
                            <p>
                                <label style='width:170px!important;'><? echo $each_skill_type .":";?></label>
                                <br><br>
                                <?
                                    for ($i=0;$i<sizeof($skills_of_skill_type);$i++)
                                    {
                                        $skill_box=$skills_of_skill_type[$i]['skill'];
                                        echo CHtml::CheckBox($skill_box,'', array (
                                        //'id'=>'used_in_gs',
                                        "onclick"=>"js:skill_check('".$skill_box."','".$each_skill_type."')",
                                        ));
                                        echo CHtml::label($skill_box, $skill_box);
                                    }
                                ?>
                            </p>
                        </fieldset>
<?
                    }

Above code is written in Yii framwork.

Now onclick of each checkbox, an calling function skill_check(),
but how to recognize whether the checkbox is checked or unchecked?

Hello,
Solved it.
I put uniq id for each checkbox.

'id'=>'skill_used'.$skill_id,
$skill_id is unique here.
and passed it in function also.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.