javascript - Passing a value to a HTML input text box and displaying it -
this first question on stackoverflow. apologies if may seem deviate rules.
i have 2 text boxes , submit button. idea is, user types number, such 7, in first input box. second input box display "seven" when submit button clicked on. first text box of id "userinput" while second 1 of id "useroutput".
as preliminary test, have following code segment in javascript doesn't seem work @ all;
function totest() { if (document.getelementbyid("inputuser").value==7) { document.getelementbyid("outputuser").value=="seven"; } else { window.alert("functionality not added"); } }
how do this?
html
firstbox <input id="first" type="text" name="fname"><br> secondbox <input id="second" type="text" name="lname"><br> <button onclick="givevalue()" type="button">click me!</button>
javascript
givevalue = function(){ console.log("hello") var value = document.getelementbyid('first').value; document.getelementbyid('second').value = value; }
js fiddle
Comments
Post a Comment