Javascript – HTML Form Submission

Submitting a HTML form in Javascript can be done by just one line.



Assume if you have a HTML form with id and name as myform.


<script type="text/javascript">
        function submitform() {
<form method="POST" name="myform" action="search.php">
        What is your name?<br/>
        <input type="text" name="visitor_name" /><br/>
        <a href="javascript: submitform()">Click me</a>


Also create the search.php

hello <?php echo $_POST["visitor_name"]; ?> !


Try it out~


Reference: How to Submit a Form Using JavaScript

Done =)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.