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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:46:40+00:00 2026-06-10T00:46:40+00:00

the code for html is : <div id=container><h1>Add-ons</h1> <input type=checkbox name=ch1 value=10 id=qr1 />Add-on

  • 0

the code for html is :

<div id="container"><h1>Add-ons</h1>
<input type="checkbox" name="ch1" value="10" id="qr1" />Add-on Number 1 - 10 QR <br />
<input type="checkbox" name="ch1" value="20" id="qr1" />Add-on Number 2 - 20 QR <br />
<input type="checkbox" name="ch1" value="40" id="qr1" />Add-on Number 3 - 40 QR <br />
<input type="checkbox" name="ch1" value="60" id="qr1" />Add-on Number 4 - 60 QR <br />
</div>

<div> I want more add-ons
<select id="more" name="more">
    <option value="0 QR">0</option>
    <option value="30 QR">1</option>
    <option value="50 QR">2</option>
    <option value="100 QR">3</option>
</select>
<span id="span"></span>
 User total usage: <span id="usertotal"> </span>

Jquery:

//For select          

      function displayVals() {
      var singleValues = $("#more").val();         
      $("#span").html("<b>more addons:</b> " + 
                  singleValues);
         }

    $("select").change(displayVals);
    displayVals();
//For  checkboxes
var $cbs = $('input[name="ch1"]');
$cbs.click(function() {
    var total = 0;
    $cbs.each(function() {
        if (this.checked)
            var singleValues = $("#more").val();
            total += +this.value + singleValues;
    });
    $("#usertotal").text(total);
});

I want at the user total usage: to create the sum of the checkboxes and add with the value of the option so that if I select 1 checkbox and 2 plus option 1 I will have written in user total usage: 60 .
Thank YOU in advance !

  • 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-10T00:46:41+00:00Added an answer on June 10, 2026 at 12:46 am

    working demo: http://jsfiddle.net/GNDAG/

    Hope it helps. You can read more about each here.

    However, like @nnnnnn mentioned, your html isn’t right — ID attributes need to be unique.

    Code

    $('input[type="checkbox"]').change(function() {
       var total_span = 0;
        $('input[type="checkbox"]').each(function() {
            if ($(this).is(':checked')) {
                total_span += parseInt($(this).prop('value'), 10);
            }
        });
    
        $("#usertotal").html(total_span);
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: HTML <div id='foo'> <input type='checkbox' value='english' name='bar[english]' /> <input
below is part of html code <div id=test1><span><input type='text' name='add'/><input type='text' name='del'/><span></div> <div id=container></div>
HTML code: <div class=clearfix style=color: #555 style=display:block; > <input type=text id=id_site placeholder=nom-du-site style=width: 245px;
This is my code : HTML: <div id="container"> <div id="box"> Content </div> </div>​ CSS:
Consider the following HTML/css code sample: <div id="container"> <div id="up">Text<br />Text<br />Text<br /></div> <div
The html code is pasted into this url http://jsfiddle.net/nzYjV/ The div (id=input) contains the
My html code is: <div title=test class=xyz>Tesing</div> I want it to look like: <a
I have some html code, so: <div class=ui-tabs-panel> <div class=dataTables_wrapper> <div> <button>Add Whatever</button> </div>
I have this HTML: <div class=region-list id=region_North_America> <strong>North America</strong> </div> and want to add
Check this code : HTML : <div style="position: absolute; visibility: visible; width: 172px;"> <img

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.