Helloooo
I just want to know how I can do to multiply a value that is in an input text by another value that is in an input text too.
I’ve tried it like this :
<div id="b" name="b">
<p id="bouz" name="bouz">Diameter (mm):</p> <p><input type="text" id="test" name="test" onblur="calculvente()"></p>
<p id="wtf" name="wtf">Width (mm):</p> <p><input type="text" id="zoubi" name="zoubi" onblur="calculvente()"></p>
</div>
</body>
<div id="c" name="c"><input type="text" id="c" name="c" onblur="calculvente()"></div>
<script>
let abc = document.getElementsById("test").value
let bac = document.getElementsById("zoubi").value
let cab = abc * bac
var select=document.getElementsById('cab')[0];
var input=document.getElementById('c');
select.onchange=function(){
input.value=select.value[select.selectedId].text;
}
</script>
But it doesn’t work and I don’t know why… If someone can explain how tf I can do that with javascript it would help me a lot. Thank you in advance 😀
2
Answers
you try to call a function named calculvente()
so you need the function
you also give the div and the input the same id. That cant work
New try:
You can just listen for the inputs with
oninput
and update the yourc
input field: