+ 1

How can I insert the value associated with a button in a text input area on the same page at runtime?

I searched a bit and came across getElementbyId.() but I don't know why it isn't working. PLEASE help. Also mention the syntax if you will.

4th Mar 2017, 2:48 PM
Shravan
3 odpowiedzi
+ 12
It's syntax like looks this: document.getElementById(the element's id); I think you put dot before bracket (that's your problem). Also use this always in function of click (not before that).
4th Mar 2017, 5:20 PM
Aydin
+ 1
if you want to change value from that in the <input value="Nigeria is awesome "> use onclick=" function()" and change the value if(onclick()) in the functions definition
4th Mar 2017, 5:25 PM
Edidiong Udoh
Edidiong Udoh - avatar
+ 1
@Aydin should I use the id of text input box or that of the button?
6th Mar 2017, 4:46 PM
Shravan