0

[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...

  • Its simple, you have to execute the same functionality but in a different occasion based on your requirement. – Krishna Prashatt Mar 01 '19 at 06:01
  • One is submitting your form as soon as page is loaded and other is when you click on submit button. Remove one of them according to your requirement then it won't submit twice. – Sagar Mar 01 '19 at 06:07
  • Actually i'm not using above two scripts same time. Consider i'm using anyone of the above script and the page reloads automatically and again the script is running. You got my problem. – Ganesh Kumar Mar 01 '19 at 06:12
  • 1
    See The Link : http://pvspondy.info/today_birthday_notification.php – Ganesh Kumar Mar 01 '19 at 06:26
  • 1
    Possible duplicate of [Using JQuery - preventing form from submitting](https://stackoverflow.com/questions/9347282/using-jquery-preventing-form-from-submitting) – Roy Bogado Mar 01 '19 at 06:32

1 Answers1

0

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>
Sagar
  • 430
  • 4
  • 14