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

  • Home
  • SEARCH
  • 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 8583733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:36:27+00:00 2026-06-11T21:36:27+00:00

I am having trouble returning only checked items from a list of items. Instead

  • 0

I am having trouble returning only checked items from a list of items. Instead of returning only the checked items, I get the full list of checkboxes: selected or not.

I have a form that returns a number of list of items with checkboxes. It seems to be working correctly, saving the users preference and correctly assigning checked="checked" to items they pick.

It is generated as follows:

foreach ($this->item as $code => $value) {
    $checked = $this->settings['item'][$code] ? "checked='checked'" : '';
    $output .= "<label style=\"margin-left: 20px;\"><input type='checkbox' {$checked} name='options[item][{$code}]'/>{$this->item[$code]}</label><br />\n\r";
}

I want to return ONLY the values of the selected checkboxes.

This is what I have been trying:

foreach ($_POST['items'] as $value) {
    echo "the value are: ".$value;
}

This returns all of the items instead of only the selected ones.

I have also tried:

$item = $this->item;
foreach($item as $code) {
    print $code;
}

This also returns all checked and non checked items.

Can anybody point me to where the problem is?

Any help is greatly appreciated!

  • 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-06-11T21:36:28+00:00Added an answer on June 11, 2026 at 9:36 pm

    I am not sure what you are asking, but I assume that you want the ones which are previously checked. So, try this:

    foreach ($_POST['items'] as $code => $value) {
        if ($this->settings['item'][$code]) {
            echo "the value are: ".$value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble returning the numberofSections/numberofRows. I have a dictionary full of data
I am having trouble returning a list given a model. The model I have:
I'm having trouble returning arrays from a custom method. It compiles fine but I
I am having trouble with my queries not returning any results. There are no
I am having trouble returning data from my sql-server database to an aspx page
I am having trouble in returning compressed response (GZip) from my Java Servlet, to
I'm having trouble getting the value from this function, I'm not sure why but
I am having trouble in returning data in php from an SQL query. here
I'm having trouble returning data from my controller using an ajax post function. What
I am having trouble on my autocomplete as it is returning only one record

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.