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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:48:32+00:00 2026-06-15T03:48:32+00:00

I have shown the problem at http://jsfiddle.net/7ZpCW/1/ I have implemented the code such that

  • 0

I have shown the problem at http://jsfiddle.net/7ZpCW/1/

I have implemented the code such that when I click on checkbox or text next to it, checkbox should be selected/de-selected depending upon its previous state.

The problem is when I click on text, though checkbox is getting checked but the alert message is getting executed only the number of times the previous checkboxes were selected.

While when I click on checkbox alert message is executed based on current state.

Screenshot

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<span id="MYARRAYloader_collapse" class = "w195"  style="display:block">
<div class="sp15">&nbsp;</div>

<div class="lf  fs12 lh15" style="padding-left:10px;">
<input type="checkbox" name="MYARRAY[]" id="MYARRAY0"  value="ALL"  checked  class="chbx checkbox-selector1">
<a href="#" class="checkbox-selector" style="color:#5B5B5B;">All</a> 
<br>
<input type="checkbox" name="MYARRAY[]"  value="V"  class="chbx checkbox-selector1">
<a href="#" class="checkbox-selector" style="color:#5B5B5B;">Opt1</a> 
<span class="gray t11">(42)</span>
<br>
<input type="checkbox" name="MYARRAY[]"  value="N"  class="chbx checkbox-selector1">
<a href="#" class="checkbox-selector" style="color:#5B5B5B;">Opt2</a> 
<span class="gray t11">(38)</span>
<br>
</div>
<div class="sp12">&nbsp;</div>
</span>

<script>
$('.checkbox-selector').click(function() {
var chb = $(this).prev();
chb.click();
return false;
})
$('.checkbox-selector1').click(function() {
var chb , chb1 , action;
chb= $(this); 
clusterName = chb.attr('name');
clusterVal = chb.attr('value');

var array = new Array();


$('input[name="'+clusterName+'"]:checked').each(function(i,el){
alert('Count Me');
chb1 = $(this); 

if(clusterVal == 'ALL')
{
if(chb1.attr('value')!='ALL')
{
chb1.attr("checked","");
}
else
array.push($(el).val());
}
else
{
if(chb1.attr('value')=='ALL')
{
chb1.attr("checked","");
}
else
{
array.push($(el).val());
}
}
});

});
</script>
  • 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-15T03:48:34+00:00Added an answer on June 15, 2026 at 3:48 am

    You are seriously convoluting this problem. You can make the text clickable simply by wrapping the checkbox and text in a label.

    <label><input type="checkbox" /> This is some text</label>
    <label><input type="checkbox" /> This is some text</label>
    <label><input type="checkbox" /> This is some text</label>
    

    jsFiddle: http://jsfiddle.net/7ZpCW/
    ​

    You should really format your code like this to make it more semantic. But you won’t. So you can fix your code by replacing this:

    $('.checkbox-selector1').click( ... );
    

    with this:

    $('.checkbox-selector1').change( ... );
    

    jsFiddle: http://jsfiddle.net/7ZpCW/2/

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

Sidebar

Related Questions

I have HTML and CSS as shown in http://jsfiddle.net/Lijo/Ydjde/ The problem is the text
I have code as shown in http://jsfiddle.net/Lijo/PJcZQ/ . It has tow divs with similar
I prepared a jsfiddle example: http://jsfiddle.net/PEH7t/11/ The problem is that I have a container
I have a fiddle here: http://jsfiddle.net/ybZvv/43/ The problem I have is with the text
I have this small testcase: http://jsfiddle.net/sV8js/ You can see that in Chrome (tested on
I have made a quick fiddle to outline my problem: http://jsfiddle.net/mYdxw/ I'm trying to
I've got the following problem (test version available http://jsfiddle.net/qmP8R/2/ ): I have two <div>
I have the following fiddle: http://jsfiddle.net/yFjtt/1/ The idea is that the user can scroll
I have a problem. Part of my app requires text to be shown in
I have created a street view backbone view. The problem is that when shown,

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.