Home >>Javascript Tutorial >submit form without submit button

submit form without submit button

Submit Form Without Submit Button

You can submit a html form without submit button using javascipt submit( ) and display the output on php page.

Here is your html form where you have to enter your input

<html>
<head>
<script>
function submitform()
{
document.getElementById("myForm").submit();
alert("your form submitted");
}
</script>
</head>
<body>
<form method="post" action="yourdata.php" id="myForm">
<input type="text" name="n" placeholder="enter your name"/><br/>
<input type="text" name="e" placeholder="enter your email"/><br/>
<input type="text" name="m" placeholder="enter your mobile"/><br/>
<textarea name="reply" placeholder="enter your address"></textarea>
</form>
<div onclick="submitform()" style="color:blue;">Submit the form by clicking this</div>
</body>
</html>

Here is your Business logic part where you will get your outut

<?php
echo "Welcome : ".$_POST['n']."<br/>";
echo "Your email : ".$_POST['e']."<br/>";
echo "Your mobile : ".$_POST['m']."<br/>";
echo "Your Adds : ".$_POST['reply'];
?>
submit_form_without_submit_button

No Sidebar ads