JavaScript Calculate 2 Numbers Form Input Text – Addition, Subtraction, Multiplication, Division



How To Calculate Two Numbers In JavaScript : sum, minus, duplication, division

Source Code:
http://1bestcsharp.blogspot.com/2017/01/javascript-addition-subtraction-multiplication-division.html

Javascript Tutorials For Beginners ➜ http://bit.ly/2k7NMWq

Javascript Course ➜ http://bit.ly/2IvBCFC

WEB-HOSTING (affiliate link) ➜ http://bit.ly/YtWebHost

visit our blog https://1bestcsharp.blogspot.com/

subscribe: http://goo.gl/nRjPKk

In This Javascript Tutorial we will See How To Calculate two Numbers ( Sum, Mutiplication, Division, Substraction )
Using Input Text, Button And Select Option For Math Operators In JS Using Netbeans Editor .

More Javascript Tutorials :

How to get value of selected radio button

How to append Value to an array

javascript images slider 1

Convert String To Number

JavaScript Show And Hide Input Password Text

change div class name in js

using checkbox with js

get And Set Value To An Input

Search Element In Array

Add Search Remove Array Element

Add HTML Table Row

Get Mouse Position

Calculator:

share this video: https://youtu.be/oDUjP4N_MtQ

Original source

32 thoughts on “JavaScript Calculate 2 Numbers Form Input Text – Addition, Subtraction, Multiplication, Division

  • June 16, 2019 at 19:11
    Permalink

    i add 2 more values in your code but it's showing "" nul "" . is it compulsory to add all values ? . how to fix it

  • June 16, 2019 at 19:11
    Permalink

    I DONNO IM DOING SOMETHING WRONG AND I CANT figure it here is my code please help me find the mistake in this
    <!DOCTYPE html>

    <html>

    <head>

    <meta name="viewpoint" content="width=device-width,initial-scale=1.0">

    <title> calculator </title>

    <script type="text/javascript">

    function calculator() {

    var n1 = parseInt (document getElementsById('n1').value);

    var n2 = parseInt (document getElementsById('n2').value);

    var oper = document getElementsById('operations').value;

    if (oper==='+') {

    var n2 = document.getElementsById('result').value=n1+n2;

    }

    if (oper==='-') {

    var n2 = document.getElementsById('result').value=n1-n2;

    }

    if (oper==='/') {

    var n2 = document.getElementsById('result').value=n1/n2;

    }

    if (oper==='x') {

    var n2 = document.getElementsById('result').value=n1 x n2;

    }

    </script>

    </head>

    <body>

    <form>

    <input type="text" id="n1" placeholder="0">

    <br>

    <input type="text" id="n2" placeholder="0">

    <select id="operations" /*disabled="operations"*/>

    <option>+</option>

    <option>-</option>

    <option>/</option>

    <option>x</option>

    </select>

    <br>

    =

    <br>

    <input type="text" name="result" id="result" disabled="result">

    <input type="button" name="GO" placeholder="GO" value="GO">

    </form>

    </body>

    </html>

  • June 16, 2019 at 19:11
    Permalink

    There's no need to write an if statement. You can also add them on this way. Here's the code.
    function myFunction() {

    var x = parseInt(document.getElementById("b1").value);

    var y = parseInt(document.getElementById("b2").value);

    var z = x + y;

    document.getElementById("demo").innerHTML = z;

    }

  • June 16, 2019 at 19:11
    Permalink

    How do you set n2 to be a fix numeric value? So for example if you wanted to calculate the price of something: n1(qty) x n2($2.50)

  • June 16, 2019 at 19:11
    Permalink

    plz add this type video : I have a four textbox. first i give one number in first box textbox and other textbox we have value , then remaining three textbox automatically decrease the value and show that textbox 0

  • June 16, 2019 at 19:11
    Permalink

    hi i look lot of videos but i cant find any thing which show how i can use code to add.
    id, code, then amount,date, update,delete. next page,
    if i want to know with code(serial number) how much amount have. or how many time i use this serial number
    serial number of a card. as bank card. but there is lot of cards. so if i want to know how many time i use it to add money or take out money..
    can you make a example of this ? THANKS

  • June 16, 2019 at 19:11
    Permalink

    this is my code.please help me … all box are appear but the function is not perform
    <!DOCTYPE html>
    <html>
    <head>
    <title>my java script page</title>
    <script type="text/javascript">
    function calc() {
    var n1 = parseInt(document.getElementById('n1').value;)
    var n2 = parseInt(document.getElementById('n2').value;)
    var operaters=document.getElementById('operaters').value
    if (operaters === '+') {
    document.getElementById('result').value=n1+n2;
    }

    }
    </script>
    </head>
    <body>
    <input type="text" id='n1' ><br>
    <input type="text" id='n2'><br>
    <select id="operaters">
    <option value="+">+</option>
    <option value="-">-</option>
    <option value="*">*</option>
    <option value="/">/</option>
    </select>

    <button onclick="calc()">=</button>
    <input type="text" id="result" >

    </body>
    </html>

  • June 16, 2019 at 19:11
    Permalink

    Is it JavaScript they use for the fantasy football websites to add your points up and everything? If so do u know a vid that shows how u do that? If not do u know what they use to do that.

Leave a Reply