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 7805937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:22:21+00:00 2026-06-02T02:22:21+00:00

Using SQL 2008 Server and the latest JQuery. If I query a column from

  • 0

Using SQL 2008 Server and the latest JQuery. If I query a column from the database and get the list/array how do I mark the checkboxes in each checkbox group ‘checked’? Example checkbox groups and lists below:

list for category ‘1,7,20’ (Jquery should mark checkboxes with values 1,7,10 checked)
list for likes ‘2,3’ (Jquery should mark checkboxes with values 2 and 3 checked)

<form>
    <input type="checkbox" class="category" name="category" value="14" />Blah
    <input type="checkbox" class="category" name="category" value="1" />Blah1
    <input type="checkbox" class="category" name="category" value="7" />Blah2
    <input type="checkbox" class="category" name="category" value="20" />Blah3
    <input type="checkbox" class="likes" name="likes" value="17" />Apple
    <input type="checkbox" class="likes" name="likes" value="3" />Apple1
    <input type="checkbox" class="likes" name="likes" value="2" />Apple2
    <input type="checkbox" class="likes" name="likes" value="13" />Apple3
</form>

I tried the following JQuery code, but it doesn’t work:

$.each(['1,7,20'], function (index, item) {
    if ($('.category').val() === item) {
        $(".category").prop("checked", true);
    }
});
  • 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-02T02:22:22+00:00Added an answer on June 2, 2026 at 2:22 am

    You’re passing an array with a single element that is the string 1,7,20, not an array with three elements that are the strings 1,7 and 20, so I’m not sure why you’re expecting it to work. If your input is in fact the string, you can split it on the comma to get an array with your numbers as strings:

    var myString = '1,7,20';
    var myArray = myString.split(',');
    

    Then pass myArray to the $.each() function call.

    There’s also a problem with the code inside the function you’ve passed to $.each(). If you do call .val() on a jQuery object containing multiple elements, it will usually return the value for the first element only. You’ll need to iterate again over the collection of elements, and use this to refer to the current element.

    $.each(myArray, function(index, item){
        $('.category').each(function(){
            if(this.value === item) {
                this.checked = true;
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Subsonic 2.2 latest SVN. SQL Server 2008 table has a column called Accreditation
I am using SQL Server 2008 and I need to select all data from
Using: SQL Server 2008 R2 I'd like to write a query that will select
I am using SQL Server 2008. I want to write a query that gives
I am using SQL Server 2008-R2 Express Edition. I wrote the query shown below
Using Sql Server 2008, developed a view vw_MasterView I get this error: Conversion failed
I'm using SQL Server 2008. My database is almost 2GB in size. 90% of
(Using SQL Server 2008) I could easily get this to work if I built
Using SQL Server 2008, is there a way to allow inserts to a table
using : SQL Server 2008 R2, Entityframework 4.3.1 my scenario : I read my

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.