Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6547475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:50:07+00:00 2026-05-25T11:50:07+00:00

I have a pages with multiple activeCheckBoxLists which are actually generated in a foreach

  • 0

I have a pages with multiple activeCheckBoxLists which are actually generated in a foreach loop. The issue that I am having is that each list is generated with the same name’s and id’s as every other generated list. I need a way to either send an iteration or something into the id’s and name’s so that they are unique.

When I use jquery to select the first item of the list it selects the first item of every list.

Here is the code that generates the lists.

// collect all filter titles (level == 0, parent == 0)
$topLevelFilterTitles = $hsf->findAllByAttributes(array('level'=>'0','parent_id'=>'0'));
foreach($topLevelFilterTitles as $filterTitle):
  // with each filter title find all children (level == 1, parent == filter title id)
  echo "<div class='half menu split'>";
  echo "<p class='uppercase-text filter-name'>" . $filterTitle->title . "</p>";
  $filterOptions = $hsf->findAllByAttributes(
     array(
    'level'=>'1',
    'parent_id'=>$filterTitle->id,
     )
  );
  $list = CHtml::listData($filterOptions,'filter_name','title');
  echo CHtml::activeCheckBoxList(
     $hsf,  // model
 'filter_name',
 $list
  );
  echo "</div>";
endforeach;

The generated lists show up as follows

<div class="halfmenu split">
   <p class="uppercase-text filter-name">Filter Name R</p>
   <input id="ytHardwareSearchFiltering_filter_name" type="hidden" value="" name="HardwareSearchFiltering[filter_name]" />
   <input id="HardwareSearchFiltering_filter_name_0" value="r_value0" type="checkbox" name="HardwareSearchFiltering[filter_name][]" /> 
   <label for="HardwareSearchFiltering_filter_name_0">r_name0</label><br/>
   <input id="HardwareSearchFiltering_filter_name_1" value="r_value1" type="checkbox" name="HardwareSearchFiltering[filter_name][]" />
   <label for="HardwareSearchFiltering_filter_name_1">r_name1</label>
</div>
<div class="halfmenu split">
   <p class="uppercase-text filter-name">Filter Name T</p>
   <input id="ytHardwareSearchFiltering_filter_name" type="hidden" value="" name="HardwareSearchFiltering[filter_name]" />
   <input id="HardwareSearchFiltering_filter_name_0" value="t_value0" type="checkbox" name="HardwareSearchFiltering[filter_name][]" /> 
   <label for="HardwareSearchFiltering_filter_name_0">t_name0</label><br/>
   <input id="HardwareSearchFiltering_filter_name_1" value="t_value1" type="checkbox" name="HardwareSearchFiltering[filter_name][]" />
   <label for="HardwareSearchFiltering_filter_name_1">t_name1</label><br/>
</div>

I need (preferably) the ID to be different between lists, but even if I could get the name different that would be a start. Thanks in advance for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:50:08+00:00Added an answer on May 25, 2026 at 11:50 am

    You can add htmloptions to the activeCheckBoxList as indicated in the API documentation. In your case I reckon you could do something like this:

    echo CHtml::activeCheckBoxList(
        $hsf,  // model
        'filter_name',
        $list, array(
            // Here you could use your filterTitle id or any other
            // variable that will make your checkbox unique
            'id'   => 'chk_'.$filterTitle->id,
            'name' => 'chk_'.$filterTitle->id
        )
    );
    

    The Htmloptions are the 4th parameter in the instantiation of activeCheckBoxList as an array. Look at the API!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say that I have an article with multiple pages. Each page has a short
I'm creating an android app that will have multiple pages with the same layout,
I have an array that I want on multiple pages, so I made it
I have a gridview control that can get loaded with multiple pages worth of
A table that extends onto multiple printed pages will have its thead and tfoot
I have some content that I want to appear on multiple pages of my
I have a 200kb file, what I use in multiple pages, but on each
I have multiple pages that have this pattern: <iframe frameborder =0 src=[someURL] width=100% height=900>
I have a situation with my MVC2 app where I have multiple pages that
I have multiple master pages in my asp.net mvc web application... Each of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.