0

Hey guys I'm trying to integrate payment gateway in my website so they have send me a code but I'm quite new to javascript now they have send code working with <body> tag and I want to use this code with <div> tag:-

<script>
    var hash = '<?php echo $hash ?>';
    function submitPayuForm() {
      if(hash == '') {
        return;
      }
      var payuForm = document.forms.payuForm;
      payuForm.submit();
    }
  </script>

executing function like this:-

<body onload="submitPayuForm()">

How does it possible with or something else.

<div onload="submitPayuForm()">
Razia sultana
  • 2,168
  • 3
  • 15
  • 20

1 Answers1

1

Div Onload Custom Script by JQuery

    var hash = '<?php echo $hash ?>';
    function submitPayuForm() {
      if(hash == '') {
        return;
      }
      //alert('here');
      //return false;
      var payuForm = document.forms.payuForm;
      payuForm.submit();
    }

$(function(){
  $('div[onload]').trigger('onload');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<div onload="submitPayuForm()">
Aman Kumar
  • 4,533
  • 3
  • 18
  • 40