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 83 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
1. Show your work to the world instead of keeping in your head💆. 2. Do the work consistently👌 3. Respect your work🥰 4. Don't postpone your work 5. Make mistakes 🔥🔥🔥