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

The Archive Base Latest Questions

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

I have a fairly simple problem (I think) that involves updating a number using

  • 0

I have a fairly simple problem (I think) that involves updating a number using jQuery. I have a DIV that holds a price for an item. Users can select a checkbox to add on to the total price. What I need is when someone clicks on a checkbox, it will add the correct amount to the DIV. When a user un-checks a checkbox, the value is subtracted. Here is my code so far:

<div class="cell">
    <div class="check">
        <input id="check-0" type="checkbox" />
        <label for="check-0">$100</label>
        <div class="mask"></div>
    </div>
</div>

<div class="price">$347</div>

Any help is greatly appreciated!

  • 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-15T02:31:50+00:00Added an answer on June 15, 2026 at 2:31 am
    var changePrice = function changePrice(amt, state){
        var curPrice = $('.price').text();
        curPrice = curPrice.substring(1, curPrice.length);
        if(state==true){
            curPrice = parseInt(curPrice) + parseInt(amt);
        }else{
            curPrice = parseInt(curPrice) - parseInt(amt);
        }
        curPrice = '$' + curPrice;
        $('.price').text(curPrice);
    }
    $(function(){
        $('#check-0').on('change', function(){
            var itemPrice = $('label[for="check-0"]').text();
            itemPrice = itemPrice.substring(1, itemPrice.length);
        changePrice(itemPrice, $('#check-0').is(':checked'));
        });
    })​;​
    

    Demo: http://jsfiddle.net/pratik136/r2Snu/

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

Sidebar

Related Questions

I have fairly simple problem but I can not think of the simple solution.
My problem in fairly simple. I have a login system constructed using php, mysql
I have a fairly simple python loop that calls a few functions, and writes
I have a fairly simple class that I want to save to SQL Server
I have recently been stuck on what I think should be a fairly simple
I have a fairly simple Psake build script (default.ps1) that calls Invoke-Psake from within
I have what I think is a fairly common problem, but I cannot seem
fairly simple question I think that I couldn't find the answer to in the
I have a fairly simple desktop application that uses a .NET setup project (.msi
I have a fairly simple question that has me stymied. I am trying to

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.