Hello,
I have created sliding fieldsets using javascripts.
in it, I have created fieldsets using for loop.
Now I want , while I click on NEXT of one fieldset , then whatever input type fields are available on that fieldset ,
I should get them.
I want to store it in temp table.
but how can I?
How to get each input type values of each fieldset?
I have created fieldset by below loop:

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 for="username" 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'];
                                        $skill_id=helpers::getSkillId($skill_box,$skill_type_id);
                                        echo CHtml::CheckBox($skill_box,'', array (
                                        'id'=>'skill_used'.$skill_id,
                                        "onclick"=>"js:skill_check('".$skill_box."','".$each_skill_type."',".$skill_id.")",
                                        ));
                                        echo CHtml::label($skill_box, $skill_box);
                                    }
                                ?>
                            </p>
                        </fieldset>
<?
                    }

Recommended Answers

All 2 Replies

if you are using jQuery:

var checkboxList = [];

// Loops each fieldset
$("fieldset.step").each(function() {

    var stepIndex = $(this).index();

    // Loops each checkbox that is checked inside of the fieldset
    $(this).find("input:checked").each(function() {

        // Adds the id to the list
        checkboxList.push({
            step: stepIndex,
            checkboxId: $(this).attr("id")
        });

    });

});

If AleMonteiro's answer works, then so should this simplification of it :

var checkboxList = $("fieldset.step input:checked").map(function() {
    return {
        'step': $(this).closest("fieldset").index(),
        'checkboxId': this.id
    };
}).get();
commented: Nice to know =) +8
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.