I think what you are trying to achieve is that you want a button which should submit the form on the click, and you have specifically said "using JavaScript", so let's go through that first.
Firstly, lets make a form:
<form id="submit_this" action="action.php" method="post">
<input>........</input>
</form>
On the HTML Part, make a button first:
<button params="values" onClick="submit_form ();">
We are interested in the onClick methos of the Button, as this will execute the submit_form ()
function on click/tap.
Now, the code for submit_form ():
function submit_form () {
document.getElementById("submit_this").submit();
}
This was specifically by using JavaScript, there are many other methods also, like, using JQuery:
$("#submit_this").submit ();
(P.S. - With JQuery, you can do a lot more than just submitting a form)
or Native HTML, In the button Markup, just keep it like this:
<button params="values" form="submit_this">
(P.S. - This is Specifically for HTML5)
Another Important Note: The params="values"
means that, there are other parameters, like class, style, etc. etc, so don't just copy-paste the code, ***You might need to modify this according to your problem*