I need to submit form by button which is out of scope of the form by JavaSript.
<form>
  <input name="data" type="text">
  <input type="submit" name="send" id="send-button" style="display: none">
</form>
<button onclick="$('#send-button').click() || .submit()"></button>
The button #send-button is visible and I need to send whole form to server. It means I receive $data and $send (both).
Now I am getting just the $data.
Any idea?
You can do with javascript form method
<button onclick="document.forms[0].submit()"></button>
if you have multiple forms in the document then set id to the form
<form id="form1">
  <input name="data" type="text">
  <input type="submit" name="send" id="send-button" style="display: none">
</form>
<button onclick="document.getElementById("form1").submit()"></button>
                        Give the form a name:
    <form name="myform">
        <a href="javascript: submitform()">Submit</a>
    </form>
Submit form function:
    <script type="text/javascript">
        function submitform()
        {
           document.myform.submit();
        }
    </script>
Invoke submission:
    document.forms["myform"].submit();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With