Skip to content
Sign upLog in
← Back to Community

How to read textboxes in JS

Profile icon
HPD1155

first you create the html text area or input:

<textarea></textarea> <input></input>

Then you give it an id:

<textarea id="input"></textarea> <input id="input"></input>

Then you create a script area:

<script src="input.js"></script>

go back to the input thing and add a <br>:

<textarea id="input"></textarea> <input id="input"></input> <br>

make a button:

<textarea id="input"></textarea> <input id="input"></input> <br> <button>click ME!</button>

add a condition to the button:

<textarea id="input"></textarea> <input id="input"></input> <br> <button onclick="">click ME!</button>

add a function:

<textarea id="input"></textarea> <input id="input"></input> <br> <button onclick="inp()">click ME!</button>

go to the js file and make that function you put in the "onclick":

function inp() { }

add the input var:

function inp() { var inp = document.getElementById("").value }

add the input ID:

function inp() { var inp = document.getElementById("input").value }

add the next following code:

function inp() { var inp = document.getElementById("input").value alert(inp) }

What this does

This will broadcast/alert the webpage your input after you entered an input and clicked the button you attached the function to.

Voters
Profile icon
HPD1155