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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:39:29+00:00 2026-05-25T18:39:29+00:00

i got following problem, i need to build a two checkboxes; where only one

  • 0

i got following problem, i need to build a two checkboxes; where only one can be selected at a time, but onchange there will be a live calculation.

$('#calculator input, #calculator select').change(function() {
    $('#calc_keller_true').click(function() {
        $('#calc_keller_false').removeAttr('checked');
    });
    $('#calc_keller_false').click(function() {
        $('#calc_keller_true').removeAttr('checked');
    });
    liveCalculate();
});

This is how it looks like, which is working but it seems to slow cause in my function liveCalculate i do this.

function liveCalculate() {
    // Getting the value of the checked checkbox
    var calc_keller = $('input[name=calc_keller]:checked').val();
    alert(calc_keller);
}

So when i click on the false button the alert will trigger before my removeAttr and both Checkboxes will be ‘checked’ at the moment of the alert.

Anyone got a plan why exactly the liveCalculate function triggers faster then the removeAttr ?

Do i miss some basic knowledge in how the order works in javascript ?

Best Regards,
jay7

  • 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-25T18:39:30+00:00Added an answer on May 25, 2026 at 6:39 pm

    You only need to add click-handlers once. In your above example, you are adding them again and again, for every ‘change’ event you have on the select box.

    Furthermore, you are not actually removing the attr on the change event, that happens during the click events. However, you fire liveCalculate after the change event.

    Consider the following:

    $('#calc_keller_true').click(function() {
        $('#calc_keller_false').removeAttr('checked');
    });
    $('#calc_keller_false').click(function() {
        $('#calc_keller_true').removeAttr('checked');
    });
    
    $('#calculator input, #calculator select').change(function() {
        $('#calc_keller_false').removeAttr('checked');
        $('#calc_keller_true').removeAttr('checked');
        liveCalculate();
    });
    

    I’m not entirely sure if that accomplishes what you’re expecting (simply because it isn’t 100% clear to me what you do expect to happen).

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

Sidebar

Related Questions

I got the following problem: There is an abstract base class, and two other
I've got following problem: (c#) There is some class (IRC bot), which has method,
I've got the following problem: I have two tables: (simplified) +--------+ +-----------+ | User
I have the following problem: I got a view with two text fields and
I'm having the following problem: When I got two labels into each other: <Label
I've got the following problem: I need to write a decorator that would be
I've got the following problem: I need to make something that checks to see
We've got the following problem. We need to display ScrollView content, consisting of a
I've got the following problem. I need to save a link to a FB
I've got the following problem; I need to create a method, which generates a

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.