How do we submit a form using JavaScript?

 Posted by vishalneeraj-24503 on 12/6/2013 | Category: JavaScript Interview questions | Views: 1688 | Points: 40
Answer:

We can write document.forms[0].submit() to submit a form in Javascript.

The submit() method submits the form same as submit button in HTML.It has no return value.Generally a Form is submitted,when we click on Submit Button.

<script type="text/javascript">

function submitform()
{
document.forms["frm_admin"].submit();
//or we can also write as
//document.getElementById("frm_admin").submit();
}
</script>


<input type="button" name="submit" value="Submit" onclick = "submitform();"/>


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response