This question already has an answer here:
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()">
</div>
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()">
</div>