Submit a Form using Javascript (Works in all Browsers)

You can submit a form using JavaScript in many ways. The way I am going to show will work in all the browsers without fail.

Look at the below script.


<script>
function submitform(){
form1.submit();
}
</script>

So, submit() is a JavaScript function that will submit form. And did you notice that form1?.
form1 is the name of the Form.

Below is the working example script where you can see the entire functionality.


<html>
<head>
<script>
function submitform(){
form1.submit();
}
</script>
</head>
<body>
<form action="" method="post" name="form1">
<input type="text" value="testvalue" />
</form>
<a href="javascript:void(0);" onclick="submitform();">Submit this Form</a>
</body>
</html>

 

 

Leave a Reply

Theme: Overlay by Kaira
Agurchand