• Thursday , 28 May 2020

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

Code Canyon



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

3d Ocean

Related Posts

32 Comments

  1. Satta Class
    June 16, 2019 at 19:11

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

  2. Satta Class
    June 16, 2019 at 19:11

    bhai iska kasa banega ?

    Example
    a+b+c+d = e

    e+ f= g

  3. balaj Zubair
    June 16, 2019 at 19:11

    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>

  4. Dhamario Gymnastiarno
    June 16, 2019 at 19:11

    thanks it good job (y)

  5. Young Fuji3001
    June 16, 2019 at 19:11

    Would a switch statement work with all this?

  6. Prasad Madushan
    June 16, 2019 at 19:11

    thanks a lot 🙂

  7. Noor
    June 16, 2019 at 19:11

    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;

    }

  8. Prottay Badhon
    June 16, 2019 at 19:11

    thanks a lot

  9. Ahsan Raza
    June 16, 2019 at 19:11

    thank u

  10. Rootica A
    June 16, 2019 at 19:11

    Great Tutorial!!
    You saved my a**
    Thanks!!

  11. jyotsna wankhede
    June 16, 2019 at 19:11

    please tell why it is not comming or tell othet methof

  12. jyotsna wankhede
    June 16, 2019 at 19:11

    i wrote all the functions properly but it is not coming in internet explorer properly

  13. seth legaspi
    June 16, 2019 at 19:11

    Whats is the problem i input 5 and 3 and to multiply it became 15555???? What happened????

  14. Madhavan Madhavan
    June 16, 2019 at 19:11

    whats happen when i give else part after the if part?

  15. Abi Krishnan
    June 16, 2019 at 19:11

    Can we also make use of radio button instead of Dropbox ?will it work the same?

  16. Chinna C RK
    June 16, 2019 at 19:11

    Very good bro… but its would be better if u added the voice.

  17. rayhanul Islam
    June 16, 2019 at 19:11

    It doesn't work

  18. Jack Singh
    June 16, 2019 at 19:11

    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)

  19. Mark Hallam
    June 16, 2019 at 19:11

    Wow great! Would putting html elements around these such as divs have any impact?

  20. Creative Tech
    June 16, 2019 at 19:11

    Thanks bhai shukriya

  21. aziz braig
    June 16, 2019 at 19:11

    Thanks
    I like it

  22. Harish Kumar
    June 16, 2019 at 19:11

    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

  23. Dra5tic
    June 16, 2019 at 19:11

    what do I do if I want add subtract to be buttons not a drop down? please help

  24. Manas Nishad
    June 16, 2019 at 19:11

    Thanks bhai it helps alot

  25. Raheel S.
    June 16, 2019 at 19:11

    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

  26. Thomas Lavoie
    June 16, 2019 at 19:11

    when I calculate 11.2 + 1.2 with the calculator the result is 12.399999999999999

    is this a bug?

  27. Kevin Sigue
    June 16, 2019 at 19:11

    does this works if multiple dots(.) will be inputted? and how to make the dot appear only once?

  28. Shafin Zaman
    June 16, 2019 at 19:11

    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>

  29. Vikram Vikram
    June 16, 2019 at 19:11

    Sir output is not shown. What can I do

  30. Muhammad Aslam
    June 16, 2019 at 19:11

    hamasaaa khush rhooo ustaaad….

  31. A7
    June 16, 2019 at 19:11

    thank u ,u helped me alot

  32. Justin Pettit
    June 16, 2019 at 19:11

    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 Comment

You must be logged in to post a comment.