How to print an input in javascript


#1

please i need a hepl to print the input text

        <p id="printhere"></p>
         Name : <input type="text" id="userName"> 
		 
        <button  onclick="display()">Add Info</button>

       <script>
function display(){

//Assigning the variable to the user input
	var userName = document.getElementById("userName").value;

// to print the input here
document.getElementById("printhere").innerHTML = userName;
}
</script>


#2

i ran your code here:

http://jsbin.com/wupusonigi/edit?html,js,output

and it ran fine


#3

Thanks.
but that’s amazingly

have been running the same thing on jsfiddle and it never worked

https://jsfiddle.net/kondasMaj/16k2fqx9/#&togetherjs=JefuRmsgya


#4

It might be a jsfiddle problem. I got this error in my console when running it on js fiddle. Running the code on jsbin ran fine


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.