+ 1

Jquery, how to get a number from an input field and plug it into another input field

Im having problems with the following code: function myFunction3() { var x = document.getElementById("myNormal").value; document.getElementById("fuskgrej").innerHTML = x; } Both myNormal and myNumber are input fields, essentially im trying to get the number that is currently inside the myNormal input field and change the number in the myNumber input field by pressing a button. Also heres the input fields: <p style="font-size: 200%" id="height1"> Current height: <input type="number" id="myNumber" value="1"></p> <p style="font-size: 200%" id="height2"> Normal height: <input type="number" id="myNormal" value="1"></p>

9th Dec 2020, 1:45 PM
Sebastian Pehrson
Sebastian Pehrson - avatar
3 Respuestas
+ 1
Sebastian Pehrson using jQuery :- $('#myNumber').val($('#myNormal').val()); using JavaScript :- document.getElementById("myNumber").value = document.getElementById("myNormal").value;
9th Dec 2020, 1:52 PM
A͢J
A͢J - avatar
+ 1
Thanks! Im still really new to all this coding stuff, this really helped!
9th Dec 2020, 2:01 PM
Sebastian Pehrson
Sebastian Pehrson - avatar
- 1
Sebastian Pehrson No problem. It happens when you learn something new.
9th Dec 2020, 2:10 PM
A͢J
A͢J - avatar