Input value | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Input value

How can i make that my userinput in javascript gets written in my input? like this <input class="in"> ___________ |__________| <---input box userinput=hello __________ |hello______| <--- final output

7th Jul 2017, 5:44 PM
TrueJu
TrueJu - avatar
6 Réponses
+ 3
First of all, I'd use "id" rather than class. <input id="in" type=text></input> Here comes the script var myInput = document.getElementById("in"); myInput.value = "hello" By the way, if it were a fully formed form, you can traverse it in different ways like "document.form[0]. elements[1]" Hope it helps.
7th Jul 2017, 6:17 PM
Ade Adeola
Ade Adeola - avatar
+ 2
var inText = document.getElementsByClassName('in'); inText.text = (inText.text + userinput);
7th Jul 2017, 5:50 PM
AgentSmith
+ 2
I found a solution for my problem, finally I finished my code :) Thank you for your help!! cookieclicker: https://code.sololearn.com/Wqm02aLadmmV/?ref=app
7th Jul 2017, 7:13 PM
TrueJu
TrueJu - avatar
+ 1
Better idea. Open up the Code Playground, write your code there, and then post the link to us so we can help you out further.
7th Jul 2017, 7:02 PM
AgentSmith
0
thank you so much i will test it out
7th Jul 2017, 6:29 PM
TrueJu
TrueJu - avatar
0
it wont work when i try it :( could you make a code so i can see what my fault is?
7th Jul 2017, 6:34 PM
TrueJu
TrueJu - avatar