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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:29:11+00:00 2026-06-15T12:29:11+00:00

Looking for a little help trying to get the value of two selected buttons,

  • 0

Looking for a little help trying to get the value of two selected buttons, add them, then output answer…

I’ve put together a js fiddle here and jQuery has never been my forté so i’m struggling to get my head around bootstrap’s radio buttons which are not actually ‘traditional’ radio buttons…

<div class="control-group">
<h4>How much you wanna give me today?</h4>
    <div class="controls">
         <div class="btn-group" id="pay-me-friend" data-toggle="buttons-radio">
              <button type="button" name="dollar" class="btn" value="100">$100</button>
              <button type="button" name="dollar" class="btn" value="200">$200</button>
              <button type="button" name="dollar" class="btn" value="300">$300</button>
              <button type="button" name="dollar" class="btn" value="400">$400</button>
         </div>
    </div>
</div>
<div class="control-group">
    <h4>How much you wanna multiply that by?</h4>
        <div class="controls">
           <div class="btn-group" id="pay-me-multiply" data-toggle="buttons-radio">
              <button type="button" name="multiple" class="btn" value="1">1</button>
              <button type="button" name="multiple" class="btn" value="2">2</button>
              <button type="button" name="multiple" class="btn" value="3">3</button>
              <button type="button" name="multiple" class="btn" value="4">4</button>
           </div>
        </div>
</div>
<hr>
<div class="well">Total amount you'll pay me: <span id="displaynumber"></span></div>

And here’s my starting point with with javascript… i should also add i’d like to use the keyup function so the answer can change on the fly..

$('#pay-me-friend > button.active').keyup(function(){    
    var no1 = $('#pay-me-friend > button.active').val(); 
    var no2 = $('#pay-me-multiply > button.active').val();    
    $('#displaynumber').html(no1 + no2);
});
  • 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-15T12:29:12+00:00Added an answer on June 15, 2026 at 12:29 pm

    There is no event you can currently tap into within Bootstrap API but a simple over-ride of the click handler they use can make it easier.

    This thread in Bootsrap issues shows they are reluctant to add this functionality:

    https://github.com/twitter/bootstrap/issues/2380

    The following will replace current click handler and add a new one with a custom event triggered within it. Just add this any time after bootstrap loads and before your code that uses it:

    $(document).off('click.button.data-api').on('click.button.data-api', '[data-toggle^=button]', function(e) {
        var $btn = $(e.target);
        if (!$btn.hasClass('btn')) {
            $btn = $btn.closest('.btn')
        };
        $btn.button('toggle');
        /* this is only change to code in bootstrap.js*/
        $btn.trigger('button_click');
    });
    

    Now within your code you can bind a handler to the custom event button_click:

    $('#pay-me-friend > button').on('button_click', function() {
        /* do calcs*/
    
    })
    

    DEMO: http://jsfiddle.net/3dPJA/1/

    You will need to modify your calculations code to make it so you don’t get NaN if both selections haven’t been made

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

Sidebar

Related Questions

I need a little help with navigating a json file. I'm looking to get
I'm looking for a little help structuring a web form to include PHP validation
So I am a little confused, I have been looking around trying to determine
I am looking for a little bit of help with jqGrid. I have a
I am trying to get the last line of a file, but my output
I'm just looking for a little guidance as to how i might implement a
I have heard conflicting stories on this topic and am looking for a little
I'm looking into the memory model a little more and am struggling with understanding
I have a little / weird behaviour here and Im looking over internet and
I'm looking into a possible feature for my little to-do application... I like the

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.