[img] http://i.imgur.com/ch761kR.png [/ img]
I have to reproduce the length converter as shown in the picture above. When you put the number in the field and press the button, it gives the result to the right of the button you selected. I started by creating buttons. Here is the code, my problem is that I do not know how to create a function that returns the result of the selected button outside the field.
Valeur:<input type="text" name="valeur" value="0" oninput="LengthConverter(this.value)"onchange="LengthConverter(this.value)"> Resultat ici<br>
<button type="button" id="inchToCm" onclick="pvc()">Pouces vers cm</button>
<button type="button" id="cmtoInch">CM vers pouces</button>
<button type="button"id="celciusToFarenheit">Celcius vers
Farenheit</button>
<button type="button" id="farenheitToCelcius">Farenheit vers Celcius</button>
I started making a function to convert lengths:
<script>
function pvc(valnum){
document.getElementById("outputCm").innerHTML=valnum/0.39370;
}
</script>
Thank you in advance
source
share