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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:48:46+00:00 2026-05-26T20:48:46+00:00

How can you add 25 when you check that box and subtract 25 when

  • 0

How can you add 25 when you check that box and subtract 25 when you uncheck it on the number that is inside the span id=”preciototal” ?

Take a look here please.
Its part of a checkout form and the idea is it calculates the total price:

http://jsfiddle.net/9YGBu/2/

  • 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-26T20:48:47+00:00Added an answer on May 26, 2026 at 8:48 pm

    As an alternative answer which demonstrates a few more advanced jQuery concepts to you, consider the following javascript:

    $(document).ready(function() {
        // cache anything reused in variables
        var $zonaenvio = $("#zonaenvio");
        var $gelypilas = $('#gelypilas');
        var $totalprecio = $('#totalprecio');
        var $totalSpan = $('#preciototal');
        // declare a function that does everything
        var updatePrice = function() {
            // get the value of the selected product, or 0 if nothing selected
            var productAmount = parseInt($zonaenvio.val() || '0');
            if (productAmount > 0) {
                // if something selected, calculate correct total and show it
                var correctTotal = productAmount + ($gelypilas.is(':checked') ? 25 : 0);
                $totalSpan.text(correctTotal);
                $totalprecio.show('slow');
            } else {
                // otherwise, if nothing selected, hide the total information
                $totalprecio.hide();
            }
        };
        // bind the function to the input events
        $zonaenvio.change(updatePrice).change(); // trigger once if needed
        $gelypilas.change(updatePrice);
    
    });
    

    Does that make sense? See here for a working jsFiddle example.

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

Sidebar

Related Questions

How can I add something in JavaScript that will check the website URL of
How can I add something in JavaScript that will check the web site URL
Im am trying to add a check box that will enable/disable the edit button.
How can i add and remove rows in datagrid using check box` [Bindable]public var
I would like to add a simple check box to my form: $element =
I am writing a windows forms application that has a check box regarding the
I need a good spell checker library for Java that can spell check a
I want to add new field in My Account page, say check box for
I have list of product.That list contain check-box & qty in Text-box.IF the user
I can add and remove the last line in my dynamic form and calculate

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.