Write inside input using JS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write inside input using JS

Can someone explain how to write inside an html input using javascript function onclick Ex <input type=text id=number> <input onclick="calculate()" type= "submit"> Now i want to write something inside the input form with id number if someone clicks on submit. What should the function calculate be then?

6th Mar 2019, 6:30 PM
sSkills
sSkills - avatar
1 Answer
+ 5
//Here by getting input field by id and changing input field value. function calculate(){ document.getElementById('number').value='hello' } https://code.sololearn.com/W0aZOm4Cj1fq/?ref=app
6th Mar 2019, 6:39 PM
Sudarshan Rai
Sudarshan Rai - avatar