10 Jul HTML5 output Tag
The HTML5 output tag shows the result of a calculation. Output the result with the output element,
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<!DOCTYPE html> <html> <head> <title>Understanding output tag</title> </head> <body> <form oninput="result.value=parseInt(val1.value)*parseInt(val2.value)"> <input type="number" name="val1" value="11" /> * <input type="range" name="val2" value="9" /> = <output name="result">99</output> </form> </body> </html> |
Here’s the output, firstly the initial values are visible i.e. output 99 for multiplication of 11 and 9,
We will drag the val2 range and now the difference can be seen easily. The output is now 1027 i.e. val2 is dragged to 79. The new output is shown below,
Attributes
- for– Specifies the list of IDs of other elements, indicating the elements contributed input values
to the calculation - form– This shows the ownership of the element associate with.
- name – The name of the element.
No Comments