submit a form with javascript onclick

submit a form with javascript, good if you want to submit a form with a button that is not within that form.

the form will require an id


<form id='theform'>
	<input type='text'>

<p>usually this would not work with a button outside the form element</p>
	<button onclick='document.getElementById("theform").submit();' class='btn btn-primary'>Submit the above form</button>



usually this would not work with a button outside the form element

Other Items in javascript

No Items Found.

Add Comment
Type in a Nick Name here
Page Views

This page has been viewed 85 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
Our brains are wired to find things we are looking for - if your always cynical or waiting for things to go wrong, then your life will reflect that. On the other hand, having a positive outlook on life will bring you joy and provide you with inspiration when you least expect it ☀ïļðŸ‰ðŸŒī