Submit a form without using a submit button using JavaScript

I have a form where i use normal buttons with javascript so i can have multiple actions and I don’t use a submit button.

If i had a submit button, it would call the javascript function, but seeing as i don’t have a submit button, how can i call that function.

HTML Code

<form id="jsform" action="demo.php" method="POST" target="_blank"> 
      <input type="text" value="test" name="title"/>                          
</form>

JavaScript Code

<script type="text/javascript">
     document.getElementById('jsform').submit();
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *