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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:23:58+00:00 2026-06-07T22:23:58+00:00

Hi making a live filter function, but having a problem to send checkbox values

  • 0

Hi making a live filter function, but having a problem to send checkbox values from different classes:

<input type="checkbox" onclick="return test();" class="type" name="type1" value="1"  /> Trousers <br />
<input type="checkbox" onclick="return test();" class="type" name="type3" value="3"  /> T-shirts <br />
<input type="checkbox" onclick="return test();" class="type" name="type2" value="2"  /> Jackets <br />

<input type="checkbox" onclick="return test();" class="color" name="color1" value="1"  /> Red <br />
<input type="checkbox" onclick="return test();" class="color" name="color3" value="3"  /> Blue <br />
<input type="checkbox" onclick="return test();" class="color" name="color2" value="2"  /> Green <br />

With this code I’m able to get values dynamicaly from all checkboxes:

function test() {
    var counter = 0, 
        i = 0,       
        url = 'items.php?',    
        input_obj = $('input[type=checkbox]');


    for (i = 0; i < input_obj.length; i++) {
        if (input_obj[i].type === 'checkbox' && input_obj[i].checked === true) {
            counter++;
            url = url + '&a=' + input_obj[i].value;
        }
    }
    if (counter > 0) {
        alert(url);

    }
}

But I need that different class have different url name (type - &a=value, color - &b=value) and combine all this to one url.

  • 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-07T22:23:59+00:00Added an answer on June 7, 2026 at 10:23 pm

    Group the checkboxes by giving them the same name (end that name with [] since you are using PHP), not by using classes. Then use serialize to generate the encoded data for your Ajax request.

    For example:

    <form>
    
    <label><input type="checkbox" name="type[]" value="1"  /> Trousers </label>
    <label><input type="checkbox" name="type[]" value="3"  /> T-shirts </label>
    <label><input type="checkbox" name="type[]" value="2"  /> Jackets </label>
    
    <label><input type="checkbox" name="color[]" value="1"  /> Red </label>
    <label><input type="checkbox" name="color[]" value="3"  /> Blue </label>
    <label><input type="checkbox" name="color[]" value="2"  /> Green </label>
    
    </form>
    

    ​
    and

    $('input[type=checkbox]').on('click', function () {
        alert($(this.form).serialize());
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making table rows click-able with jQuery's $.live() function. Works perfectly on Chrome, Firefox
I am making a live search box and it seems that if I type
I'm testing out making an entry system but the problem is, my host's timezone
I have been making a live wallpaper and have finally succeeded so far, but
I'm making a live wallpaper app and I was just wondering if I can
Making a new site but something is happening to it in IE8. The social
Making a new site but something is happening to it in IE. I've purchased
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
Making websites that appear correctly in IE is a big problem. Is there any
So I am learning about javascript, so I am making a live chat system

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.