简体   繁体   中英

Submit Form Only once

[Repeatedly I'm getting Notifications]. Actually, I just want to run the PHP script in cron job and i found two alternatives to submit form automatically and to click button automatically.

But these scripts are repeatedly doing it. I need to run only once.

One by using form id:

<script>
    function submitForm() {
        document.getElementById("form").submit();
    }
    window.onload=submitForm;
</script>

Another by using Button id:

<script>
    jQuery(function(){
      jQuery('#submit').click();
      return false;
    });
</script>

Can Anyone Help Me...

use sessionStorage .

<script>

   function submitForm() {
    var IsSubmit = sessionStorage.getItem("IsSubmit") || "N";
    if(IsSubmit === "Y")
    {
           document.getElementById("form").submit();
           sessionStorage.setItem("IsSubmit","Y")
    }
        }
        window.onload=submitForm;

</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM