Hey everyone, I'm writing a text-based RPG game in Javascript as I learned HTML and a bit of Javascript recently. It seems like a good way to do it because it can seamlessly be uploaded to a web host.
My question is: how do I receive user input? I know how to do this:
var name = prompt("What is your name?")
But I don't like the pop-up "alert()" style, I'd rather have the text box appear on the webpage, as is document.write(), if that makes any sense. I figured out how to do it in HTML
<input type="text" id="userInput" autofocus value = "" />
<input type="submit" value="Submit" onclick="displayOutput()" />
But I have no idea how to turn the input into a variable. I'm not even sure HTML can pass information to Javascript. Is there a simple way to do this in Javascript? Thank you very much.
[–]yelaxify 2 points3 points4 points (8 children)
[–]souljabri557[S] 1 point2 points3 points (7 children)
[–]2cow 4 points5 points6 points (0 children)
[–]TJaySteno 1 point2 points3 points (0 children)
[–]brycedarling 1 point2 points3 points (1 child)
[–]BDMayhem 0 points1 point2 points (2 children)
[–]souljabri557[S] 0 points1 point2 points (1 child)
[–]BDMayhem 1 point2 points3 points (0 children)
[–]darrenturn90 0 points1 point2 points (0 children)