instantaneous javascript computations

Click the link below to view the code. Currently, the issue I am facing is that the bottom three sets of checkboxes are not performing the correct calculations and do not update when they are unchecked.

Visit Code

$('input[name=food]').change(function(){
    if($(this).is(':checked')){
      gettotal();
    }
    else{
    }
});  

// This piece of code verifies whether the checkboxes with name "food" have been checked, identifies which one was checked, and then triggers the 'get total' function.

Answer №1

Implement

$(".your-input").on("input", function(){ // });

This will update in real-time, not just when the input field loses focus.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jQuery Does Not Iterate Through Arrays

I am encountering an issue where I am trying to populate an array with images and then pass them to a variable called $image. However, when I attempt to iterate over this array, the same item is being alerted three times. Here is the problematic code snip ...

Guide on retrieving the initial value from a map in a React application

In my React project, I am working with a map that has string keys and values. Here's an example: let map = new Map(); map.set("foo", "bar"); map.set("foo-bar", "bar-foo"); What is the best way to retrieve the first value from this map? ...

Strange occurrences with the IMG tag

There seems to be an issue with my IMG element on the webpage. Even though I have set the height and width to 100%, there is some extra space at the end of the image. You can view the problem here: I have also included a screenshot from the developer too ...

What is the best way to determine whether a YouTube video permits embedded playback?

When working with user-generated content, it's important to note that YouTube channels may restrict their videos from being played in an embedded player. In order to provide a better user experience, I need to detect the specific reason why a video ca ...

Unable to place the div at the bottom of its parent div

I've encountered an issue with the code below and I'm not sure what I'm doing wrong. It seems to work in Dreamweaver, although not in live view, but it sticks to the top and left in Safari and Firefox. I attempted replacing the masthead div ...

Is there a way to customize the font size of Material UI Autocomplete?

I'm currently trying to customize the Material UI Autocomplete component with my own CSS. Specifically, I aim to adjust the font size of the input field. Below is my current implementation: <Autocomplete style={{ width: 200, height: 60, ...

Incorrect handling of Unix timestamps in AngularJS

I'm facing an issue with timestamps. Let me explain - I have a timestamp coded as 1378028575, which corresponds to Sun, 01 Sep 2013 09:42:55 GMT according to this website. The problem arises when I attempt to format this timestamp using Angular's ...

Is it better to submit a form via ajax using one method or two methods?

Which option is better between the following two: 1. $.post( '/ajax/action', function(data) { doResult(); } ); *This option involves two receptors: ajax.php and action.php* or 2. $.post( '/action', { typerequest: 'ajax' } ...

Issue with Bootstrap 3 columns not arranging correctly

Utilizing Bootstrap 3, I am attempting to stack grids on top of each other in the order of A, B, C, D, E. While the mobile grid stacking works well, the issue arises when viewing it on desktop where the grids do not align as expected, particularly the box ...

Translating MySQL data into JavaScript using PHP

Hey everyone, I'm having trouble utilizing MySQL row values in JavaScript. Despite experimenting with various combinations of quotes and double-quotes. $sql = "SELECT desk_id, desk_x, desk_y FROM desks"; $result = $conn->query($sql); if ($result- ...

What is the method for opening a page using a fancybox popup?

I have experience using fancybox popups by creating a link that opens the fancybox when clicked. However, the new requirement is that if the user clicks on a link without being logged in, the page should refresh with the popup already open. Can this be ...

Having trouble getting two divs to align on the same line using the 'inline' method

I am struggling to align multiple buttons within divs on the same line. Two of these buttons should only be displayed when a specific value is greater than 0. I attempted using display:inline-block in a container div, along with style="float:right", but it ...

Enhance Your CSS Abilities with These Helpful Guides

Over the past month, I've immersed myself in learning CSS. My journey began with devouring all the information I could find on www.w3school.com, followed by delving into CSS Mastery 2nd edition. While I have successfully built a couple of websites, I ...

When using Flask, adding type=module to the src tag in HTML causes JavaScript to cease functioning

The task I had anticipated to be the simplest component of my project has transformed into a monumental challenge. My initial objective was to extract data from a JSON file for display on my website. Prior to implementing the JSON file, I manually input so ...

Ways to identify a mobile device

My website uses Javascript to detect when someone is accessing it from a mobile device. This detection method was effective until Apple updated their iPad OS from IOS 13.1 to iPadOS 13.1. The code I use for detection is as follows: if( /Android|webOS|iPh ...

How to use Axios in Vue JS to access an array within a JSON object

Struggling to access arrays inside a JSON object and save them into separate arrays. Despite trying various methods, I have not been successful in retrieving these arrays. I suspect that my approach to accessing arrays within the JSON object is incorrect, ...

The Input element's onChange event is not functioning as expected

I am experiencing some issues with my code. I am trying to dynamically change the background color based on user input, but I am struggling to make it work. It seems like a simple task, so I must be missing something. Below is my HTML markup and jQuery: ...

A guide on extracting the geometry from an STL model imported into three.js

After using STLLoader to load an STL file into three.js, I am trying to access the vertices and geometry of the model for further use. However, I am encountering difficulty in retrieving the geometry after calling the loader. How can I achieve this? Belo ...

Having trouble with jQuery selecting a specific span class?

I'm attempting to use the (.class) selector to select the span element, but for some reason it's not working as expected. <div class="text-wrap"> <div class="text-list"> <div class="text-suggestion"> <span class="text ...

Why is my NextJs app loading slowly on Safari but quickly on Chrome?

Currently, I am in the process of developing a web app using nextjs. I have encountered some issues with linking to pages, particularly the home page which contains multiple svgs and images. The performance lags when using Safari, as it does not show a loa ...