Search This Blog

2023/04/21

Output Tag in HTML

 In output tag we are displaying sum of one input type text other input type

range.

the for attribute in output is A space-separated list of other elements' ids,
indicating that those elements contributed input values to (or otherwise
affected) the calculation.

Here note that we are accesing controls in javascript directly from their
ids not using document.getElementById

<form method="get" oninput="sum()">
<input type="range" id="a" name="a" min="0" max="100" onchange="display()"/>
<span id="rangeVal"></span>

<input type="text" id="b" name="b" value="50"/>
<output name="o" id="o" for="= a b" />
<script>
function sum(){
var aval = a.value
var bval = b.value
o.value = parseInt(aval) + parseInt(bval)
}
function display(){
var aval = a.value
var rangeValObj = rangeVal.innerText = aval
}
</script>
</form>

No comments:

Post a Comment