How cn i code window in witch you can type the answer | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
- 1

How cn i code window in witch you can type the answer

17th Jul 2017, 10:41 PM
Luka Krsikapa
Luka Krsikapa - avatar
18 Réponses
+ 5
The right answer is to rather use the prompt() box function, and not the alert() one (neither the confirm() ^^)... But anyway, for handling interactivity/user input, don't use alert/prompt/confirm ps modal windows: that's not user friendly at all :P You should implement (write or use ready made) user input, output with html elements to keep the user interface inside the web document ;) Example of such integration/replacement with pure JS of an original code of such real html substitute on another sololearners game improvments: https://code.sololearn.com/Wp8x1NemoYJ1/?ref=app Or just implementation of sooner adaptation of a customized yes/no box, also in original pure JS: https://code.sololearn.com/WO2Mz12InjfP/?ref=app And the yes/no box code: https://code.sololearn.com/WlSiILvqHwd9/?ref=app
18th Jul 2017, 12:19 AM
visph
visph - avatar
+ 4
If you have been less lazy and did study my answer/codes, you would have seen that using <input> html form element was the other way to do ^^
18th Jul 2017, 12:12 PM
visph
visph - avatar
+ 3
too much? :D
18th Jul 2017, 12:23 AM
visph
visph - avatar
+ 3
Well, I will forgot you the next time, if you don't like accurate answer and time taken for you ^^
18th Jul 2017, 12:30 AM
visph
visph - avatar
+ 1
var x = prompt ('enter your name'); alert(x);
17th Jul 2017, 11:20 PM
seun sola
seun sola - avatar
+ 1
You can also use the HTML <input> tag. HTML: <input id="answer"> JavaScript: var answerBox = document.getElementById("answer"); var answer = answerBox.value; The variable answer now stores whatever value the user entered before the above lines of code were triggered. You can use a <button> to trigger a function (ie submit the answer) using the attribute onclick="func();".
18th Jul 2017, 9:09 AM
James
James - avatar
0
I don't understand. you mean like a prompt in which you request for user input?
17th Jul 2017, 11:04 PM
seun sola
seun sola - avatar
0
yes
17th Jul 2017, 11:08 PM
Luka Krsikapa
Luka Krsikapa - avatar
0
what can u type some short code just to sho me
17th Jul 2017, 11:12 PM
Luka Krsikapa
Luka Krsikapa - avatar
0
thx
17th Jul 2017, 11:20 PM
Luka Krsikapa
Luka Krsikapa - avatar
0
im making a game i will tell when im done
17th Jul 2017, 11:20 PM
Luka Krsikapa
Luka Krsikapa - avatar
0
Okay. can't wait to see.
17th Jul 2017, 11:21 PM
seun sola
seun sola - avatar
0
that is one very long reply
18th Jul 2017, 12:22 AM
Luka Krsikapa
Luka Krsikapa - avatar
0
ok ok sry
18th Jul 2017, 12:33 AM
Luka Krsikapa
Luka Krsikapa - avatar
0
visph Thank you for the very detailed response to my question, I am sorry I replied to you like that. I came back to see the old projects and comments and I really cringed when I was reading this one. The way I talked to others was just wrong.
22nd Dec 2020, 9:34 AM
Luka Krsikapa
Luka Krsikapa - avatar
- 1
tooooooo much
18th Jul 2017, 12:25 AM
Luka Krsikapa
Luka Krsikapa - avatar
- 1
just show me what do u type wjen u want dat box to appear
18th Jul 2017, 12:34 AM
Luka Krsikapa
Luka Krsikapa - avatar
- 1
thx
18th Jul 2017, 9:17 AM
Luka Krsikapa
Luka Krsikapa - avatar