NEWS: Total Picture Views: 147066 | Total Article Views: 155673 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. How to read a JSON and work with it | 3. PickUpThings with Becker Robot | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

Get Values Addition And Print The Value Javascript


In this example I will be showing an example of addition 2 numbers and print the value in the paragraph tag.

You can see the working demo here:


<!DOCTYPE html>
    <title>Example 5</title>
<script type="text/javascript">
    function calculate(){
        var input1 = document.getElementById("input1").value;
        var input2 = document.getElementById("input2").value;

        var answer;

        answer = parseInt(input1) + parseInt(input2);
        document.getElementById("answer").innerHTML = ("The answer is " + answer);

Number 1:<input type="number" id="input1"><br>
Number 2:<input type="number" id="input2"><br>
<button onclick="calculate()">Calculate</button>
<p id="answer"></p>
Attachments: None

Tags: innerHtml document getElementById Function Parse

Total Views: 800

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 01/19/15 and updated on 01/19/15


Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.