Skip to content

Instantly share code, notes, and snippets.

@plembo
Created April 11, 2018 21:06
Show Gist options
  • Save plembo/44d6f21340c0742a28666b98b27415cc to your computer and use it in GitHub Desktop.
Save plembo/44d6f21340c0742a28666b98b27415cc to your computer and use it in GitHub Desktop.
Post form input to a new page using javascript

This code will post form input to a new page using javascript. Very simple.

Found here:

https://stackoverflow.com/questions/12887702/javascript-display-new-page-when-submit-html-form

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test Page</title>

        <script type="text/javascript">
            function display() {
                document.write("You entered: " + document.myform.data.value);
            }  
        </script>
    </head>
    <body>
        <form name="myform">
            <input type="text" name="data">
            <input type="submit" value="Submit" onClick="display()">
        </form>
    </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment