Auto submit form on page load

后端 未结 4 1453
粉色の甜心
粉色の甜心 2020-12-23 21:28

I\'m having a bit of trouble with my current issue. Any help would be greatly appreciated.

I have a step in a \'signup process\' which I don\'t need anymore, but I d

相关标签:
4条回答
  • 2020-12-23 21:44

    You can submit any form automatically on page load simply by adding a snippet of javascript code to your body tag referencing the form name like this....

    <body onload="document.form1.submit()">
    
    0 讨论(0)
  • 2020-12-23 21:48

    This is the way it worked for me, because with other methods the form was sent empty:

    <form name="yourform" id="yourform" method="POST" action="yourpage.html">
        <input type=hidden name="data" value="yourdata">
        <input type="submit" id="send" name="send" value="Send">
    </form>
    <script>            
        document.addEventListener("DOMContentLoaded", function(event) {
                document.createElement('form').submit.call(document.getElementById('yourform'));
                });         
    </script>
    
    0 讨论(0)
  • 2020-12-23 21:54

    Try this On window load submit your form.

    window.onload = function(){
      document.forms['member_signup'].submit();
    }
    
    0 讨论(0)
  • 2020-12-23 21:54

    Add the following to Body tag,

    <body onload="document.forms['member_signup'].submit()">
    

    and give name attribute to your Form.

    <form method="POST" action="" name="member_signup">
    
    0 讨论(0)
提交回复
热议问题