When the user enters value in feet, the application should calculate the meter equivalent and display the same in meter textfield.
Formula : 1ft = 0.3048m
When the user enters a value in the meter, the application should calculate the feet equivalent and display the same in feet text field.
Formula : 1m = 3.2808ft
Need to update both values simultaneously when I enter either of the input fields.
Here is my code:
function LengthConverter(val) {
var input2 = document.getElementById("meter").innerHTML = val / 3.2808;
console.log(input2);
val.value = input2.value;
}
<div class="container">
<div class='ftm'>
<label for="feet">Feet:</label><br>
<input id="feet" type="number" placeholder="Feet" onchange="LengthConverter(this.value)">
</div>
<div class='ftm'>
<label for="meter">Meter:</label><br>
<input id="meter" type="number" placeholder="Meters">
</div>
</div>