Javascript: A simple form

This entry is part 18 of 27 in the series Javascript Tutorial

A simple textbox input form.

<!DOCTYPE html>
<html>
<head>
    <title>Test input</title>
    <script>
        function submitForm(form) {
            var text_input = form.inputbox.value;
            document.getElementById("text_id").innerHTML=text_input;
        }
    </script>
</head>
<body>
<form>Enter something in the box: <br><br>
    <input type="text" name="inputbox" value=""><P>
        <input type="button" name="button" value="Click" onClick="submitForm(this.form)">
</form>
<p id="text_id">You typed</p>
</body>
</html>
Take note of how the text you typed into the text box is passed into variable text_input.
var text_input = form.inputbox.value;
Series Navigation<< Javascript: Array
Javascript: Form with radio buttons >>