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

https://jsfiddle.net/64w6yjxv/4/


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -