Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to add multiple input value in javascript

 $(document).ready(function(){

    //iterate through each textboxes and add keyup
    //handler to trigger sum event
    $(".input-number").each(function() {

        $(this).keyup(function(){
            calculateSum();
        });
    });

});

function calculateSum() {

    var sum = 0;
    //iterate through each textboxes and add the values
    $(".input-number").each(function() {

        //add only if the value is number
        if(!isNaN(this.value) && this.value.length!=0) {
            sum += parseFloat(this.value);
        }

    });
    //.toFixed() method will roundoff the final sum to 2 decimal places
    $("#sum").html(sum.toFixed(2));
}
Comment

How to display multiple input value in JavaScript

//two input fields displayed as one
// <p>{input.value}${time.value}</p>
addBtn.addEventListener('click', () => {
    if (input.value.trim() != 0) {
        let newItem = document.createElement('div');
        newItem.classList.add('item');
        newItem.innerHTML = `
        <p>${input.value}${time.value}<p>
        <div class="item-btn">
        <i class="fa-regular fa-pen-to-square"></i>
        <i class="fa-regular fa-trash-can"></i>
    </div>
        `;
        tasks.appendChild(newItem);
        input.value = "";
    } else {
        alert('Please enter a task')
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: react table handling multiple selected checkbox 
Javascript :: Or Or Equals 
Javascript :: object destructuring es6 
Javascript :: key codes javascript 
Javascript :: getting started with react 
Javascript :: js some 
Javascript :: CHECKING TYPE OF ARRAY 
Javascript :: Authentication handling in javascript 
Javascript :: how to change Mime type of a file express 
Javascript :: vuejs events modifier 
Javascript :: How to pass methods in vue js 
Javascript :: property binding angular 
Javascript :: can i use splice in string of javascript 
Javascript :: append item to array javascript 
Javascript :: react usememo hook 
Javascript :: run two function after one another 
Javascript :: javascript string literal 
Javascript :: random name 
Javascript :: match if 
Javascript :: nextjs sitemap generator 
Javascript :: create your own programming language in javascript 
Javascript :: sequelize attributes exclude all 
Javascript :: object initializer in javascript 
Javascript :: alert in react native 
Javascript :: Find a palindrome using Array methods 
Javascript :: json date format 
Javascript :: combineReducers. 
Javascript :: toggle class jquery 
Javascript :: query selector js 
Javascript :: run only one test cypress 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =