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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:26:36+00:00 2026-05-16T12:26:36+00:00

I’m trying to write a script where the unchecked values of a set of

  • 0

I’m trying to write a script where the unchecked values of a set of check-box are removed from a cookie. I am using jQuery’s cookie plugin below is my current function which is called when a check-box is called;

<script type="text/javascript">
 jQuery(document).ready(function($){
    $("input[type=checkbox]").each(function () {
      $(this).change(updateCount);
    });

    updateCount();

    function updateCount () {

      var val;
      var my_cookie
      var new_my_cookie;

    $(':checkbox:checked').each(function(){
      val= $(this).val();
      my_cookie=$.cookie("chosen_ones");
      $.cookie("chosen_ones", null);
      new_my_cookie=my_cookie+"|"+val;
      $.cookie("chosen_ones", new_my_cookie);
    });

    //somehow need to remove values from cookie when unchecked here

      var length = $.cookie("chosen_ones").split("|").length;
      length=length-1;
      $("#count").text(length);
      $("#status").toggle(length >= 0);
    };
  });
</script>

Any help would be welcomed.

  • 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-16T12:26:37+00:00Added an answer on May 16, 2026 at 12:26 pm

    If you need an answer without json2 ( I mean not everybody knows json2 ) you can use this answer; (And if you like it maybe you could rate it 😀 )

    <script type="text/javascript">
    
    //Adds new uniqueArr values to temp array
        function uniqueArr(a) {
         temp = new Array();
         for(i=0;i<a.length;i++){
          if(!contains(temp, a[i])){
           temp.length+=1;
           temp[temp.length-1]=a[i];
          }
         }
         return temp;
        }
    
    
        //Will check for the Uniqueness
        function contains(a, e) {
         for(j=0;j<a.length;j++)if(a[j]==e)return true;
         return false;
        }
    
     jQuery(document).ready(function($){
        $("input[type=checkbox]").each(function () {
          $(this).change(updateCount);
        });
    
        updateCount();
    
    
    
        function updateCount () {
    
          var val;
          var my_cookie="";
          var new_my_cookie="";
          var cookie_array;
          var new_cookie_array;
          var new_cookie_string="";
          var number=0;
          var temp_cookie="";
    
          my_cookie=$.cookie("chosen_ones");
    
        $(':checkbox:checked').each(function(){
          val= $(this).val();
          if((val!=null)&&(val!="")){
            my_cookie=val+"|"+my_cookie;
          }
    
    
        });
    
        new_cookie_array=uniqueArr(my_cookie.split("|"));
    
        $.each(new_cookie_array, function(index, values) {
                if((values!="")&&(values!="null")&&(values!=null)){
                    temp_cookie=values+"|"+temp_cookie;
                }
            });
    
        $.cookie("chosen_ones", null);
        $.cookie("chosen_ones", temp_cookie);
    
        var cookie_array=$.cookie("chosen_ones").split("|");
    
        $(':checkbox:not(:checked)').each(function(){
          val= $(this).val();
          $.each(cookie_array, function(index, values) {
                   if((values==val)&&(values!=null)&&(values!="")&&(values!="null")&&(values!="")){
                    cookie_array[index]="";
                }
            });
        });
    
          new_cookie_array=uniqueArr(cookie_array);
    
          $.each(new_cookie_array, function(index, values) {
                if((values!="")&&(values!=null)&&(values!="null")){
                    new_cookie_string=new_cookie_string+"|"+values;
                }
            });
    
          $.cookie("chosen_ones", null);
          $.cookie("chosen_ones", new_cookie_string);
          alert($.cookie("chosen_ones"));
          var temping_string=$.cookie("chosen_ones");
          $("#count").text(temping_string.split("|").length-1);
          $("#status").toggle(temping_string.split("|").length-1 >= 0);
        };
      });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:

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.