Skip to content Skip to sidebar Skip to footer

Js - How To Submit Form Onclick And Send Submit Button

I need to submit form by button which is out of scope of the form by JavaSript.
Copy

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>

Solution 2:

Give the form a name:

<formname="myform"><ahref="javascript: submitform()">Submit</a></form>

Submit form function:

<scripttype="text/javascript">functionsubmitform()
        {
           document.myform.submit();
        }
    </script>

Invoke submission:

    document.forms["myform"].submit();

Solution 3:

you should add value attribute on submit button like that

<inputtype="submit" name="send" value="xyz"id="send-button" style="display: none">

i think you will received both values

Post a Comment for "Js - How To Submit Form Onclick And Send Submit Button"