HTML5: How to specify one or more forms the output element belongs to?
Solution:
HTML Code:
Explanation:
- This HTML code demonstrates how to specify one or more forms that an <output> element belongs to.
- Here's the breakdown:
- The document starts with the declaration of the document type and contains various elements.
- The form with the ID MyForm contains two input elements: a range input and a number input.
- JavaScript code within the oninput attribute of the form calculates the sum of the values entered into the input fields (after parsing them as integers).
- The parseInt() function is used to convert the input values from strings to integers for proper addition.
- The <input> elements are associated with the form MyForm through their respective name attributes.
- The <output> element with the name second_output is associated with the form MyForm using the form attribute.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.