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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:43:24+00:00 2026-05-25T01:43:24+00:00

I am currently developing a shopping cart solution and I have a field, which

  • 0

I am currently developing a shopping cart solution and I have a field, which is used for tax.

What I’m looking to do, is when the user selects the checkbox field for tax, then this is stored in the cookie, so when they go to other pages and then return to the cart, then these fields are checked.

I am using http://plugins.jquery.com/project/Cookie to achieve this.

I can create the cookie for the checkboxes, but I am struggling to then check the cookie and if it was for a checkbox, then set the checkbox as ‘checked’.
I also need, the deletion of cookies. When the user unchecks the box, to the call something like $.cookie(“vat_1”, null)

I have the following code so far:

$(document).ready( function() {
    $('input:checkbox[name="<?php echo $prod; ?>"]').click(function() { 
        var name = $(this).attr("name"); 
        var value = $(this).val(); 
        var date = new Date();
        date.setTime(date.getTime() + (30 * 60 * 1000));

        $.cookie(name, value, { expires: date });//Set the expires time as per your requirement.  
        cookie = $.cookie(name);

        alert(cookie);    
    }) 
});

All help is muchly appreciated.

Thanks

  • 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-25T01:43:24+00:00Added an answer on May 25, 2026 at 1:43 am

    To support loading the previously checked boxes, at the top of the document.ready() function, insert the following code:

    $('input:checkbox').each(function(index) {
        cookie = $.cookie($(this).attr("name"));
        if (cookie == 1) {
            $(this).prop('checked', true);
    });
    

    This should loop through each checkbox on the page, lookup the relevant cookie, and alter the checkbox accordingly.

    In terms of deleting the cookies and setting them correctly in the first place, you should not be using the val() of the checkbox. Instead you should be looking up its checked property:

    $('input:checkbox[name="<?php echo $prod; ?>"]').click(function() { 
        var name = $(this).attr("name"); 
        var value = $(this).prop('checked'); 
        var date = new Date();
        date.setTime(date.getTime() + (30 * 60 * 1000));
    
        if (value) {
            $.cookie(name, 1, { expires: date });
        } else {
            $.cookie(name, null);
        }
    
        cookie = $.cookie(name);
    
        alert(cookie);    
    })
    

    These two pieces of code should be combined as such

    $(document).ready( function() {
        //first code above
        //second code above
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently involved with developing a C# CMS-like web application which will be used
I am currently developing an approval routing WCF service that will allow an user
I am currently developing a simple eCommerce site. I am looking for a lightweight
I have a prospective client that currently uses Miva Merchant as their e-commerce solution.
Currently developing a PHP framework and have ran into my first problem. I need
We are currently developing a server whereby a client requests interest in changes to
I was currently developing a desktop application in C# using mono and testing in
I am currently developing a Rails application using a database that was designed before
I'm currently developing for a handheld device running Windows XP Professional (not Tablet PC
I'm currently developing a PHP application that's using an Access database as a backend.

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.