How to include the result of a calculation in HTML5?

HTMLFront End TechnologyWeb Development

Use the <output> tag in HTML5 to specify the result of a calculation. The HTML <output> tag also supports the following additional attributes −

Attribute
Value
Description
for
for
List of IDs of other elements, i.e. it indicates the elements who have contributed input value to the calculation.
form
form
Enables to place output elements anywhere within a document.
name
name
It is the name of the element.

Example

You can try to run the following code to learn how to implement <output> tag in HTML5 −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Output Tag</title>
   </head>
   <body>
      <form oninput = "sumresult.value = parseInt(z1.value)+parseInt(z2.value)+parseInt(z3.value)">
         <input type = "range" name = "z1" value = "0" /> +
         <input type = "number" name = "z2" value = "30" /> +
         <input type = "number" name = "z3" value = "60" /><br />
         The output is: <output name = "sumresult"></output>
      </form>
   </body>
</html>
raja
Published on 13-Mar-2018 08:19:57
Advertisements