Ask coding questions

← Back to all posts
user input in Javascript
quirkygirls (1)

I am trying to get user input with my html page in javascript however it will not work and i cannot for the life of me figure out why. would massively appreciate some advice <3

Comments
hotnewtop
[deleted]

You are using a nodejs repl right now, you will want to create a html/css/js repl.

Furthermore, you need to make a proper html file. It's missing html, body and even the javascript isn't linked through the script tag.

<DOCTYPE html>
    <body>
        <input id="usernameInput" type="text" placeholder="username">
        <br>
        <input id="email" type="text" placeholder="Emai address">
        <br>
        <input id="subject" type="text" placeholder="Subject">
        <br>
        <textarea id="comment" placeholder="message" rows="5" cols="22"> 
        </textarea>
        <button onclick="submit()">Submit</button>
        <p id ="hello"></p>
    </body>
</html>

I might have missed something but let me know how it works when you've put it in a html/css/js repl.

quirkygirls (1)

@RogueHalo Hi I posted all of my code now before i posted just a section. Thank you for taking a look

[deleted]

@quirkygirls So it all works as expected now?

quirkygirls (1)

@RogueHalo nope. the javascript doesnt run.

[deleted]

@quirkygirls Cool, change the repl linked on here to the new one and i'll take a look.

AdCharityTester (11)

@quirkygirls your html file looks perfectly valid. The main problem, as RogueHalo pointed out, is that you don't have an html, css, js repl set up. Node.js is essentially just pure Javascript intended for servers. Simply making a new repl with the html/css/js option with the same code should work. You could also circumvent the issue by creating a server, but for convenience that's not necessary.