Open In App

Which tag is used for representing the result of a calculation ?

In this article, we will know which tag will be useful for rendering the calculation result. The main problem is to calculate the two or more numbers based on the user input & accordingly render the output for the calculation. For displaying the output, we will use the <output> tag which is used to represent the result of a calculation. This tag can also be used for the calculation of large & complex numbers. We can use <number> tag as well as <range> tag also. All these operations will be performed inside the <form> tag.

Important Terminology Used:



Approach:

Example 1: Here, we have only used the inputs as a number type.






<!DOCTYPE html>
<html>
  
<body bgcolor="lightblue">
    <h1>The GeeksforGeeks Output Example</h1>
    <form oninput=
"sou.value=parseInt(gfg.value)*parseInt(gho.value)-parseInt(ar.value)">
        <input type="number" id="gfg" value="10"> x
        <input type="number" id="gho" value="10"> -
        <input type="number" id="ar" value="100"> =
        <output name="sou" for="gfg gho ar"></output>
    </form>
</body>
  
</html>

Output:

HTML <output> tag

Example 2: Here, we have used two inputs as number type & one as range type. Here, we have only changed the second input type as the range.




<!DOCTYPE html>
<html>
  
<body bgcolor="lightblue">
    <h1>The GeeksforGeeks Output Example</h1>
    <form oninput=
"sou.value=parseInt(gfg.value)*parseInt(gho.value)-parseInt(ar.value)">
        <input type="number" id="gfg" value="10"> x
        <input type="range" id="gho" value="10"> -
        <input type="number" id="ar" value="100"> =
        <output name="sou" for="gfg gho ar"></output>
    </form>
</body>
  
</html>

Output:

HTML <input> element with range value


Article Tags :