在cakephp页面中自动提交表单

时间:2014-12-11 12:04:31

标签: javascript

我有一种情况,我想在cakephp ctp文件中自动提交表单。谁能帮帮我吗?我知道在此之前有很多相同或类似的问题。它尝试了一切,但它不起作用。请查看我的代码:

脚本部分:

<script>
window.onload = function() {
        alert("reached here");
        document.frmTransaction.submit();
    }
</script>

HTML PART:

<form method="post" action="https://secure.ebs.in/pg/ma/sale/pay" name="frmTransaction" id="frmTransaction" onSubmit="return validate()" onLoad="javascript:autoSubmit();">
    <input name="account_id" type="hidden" value="<?echo $_POST['account_id'] ?>" />
    <input name="return_url" type="hidden" size="60" value="<?echo $_POST['return_url'] ?>" />
    <input name="mode" type="hidden" size="60" value="<? echo $_POST['mode']?>" />
    <table style="width:50%">
        <tr>
            <td>Reference:&nbsp;</td><td><input name="reference_no" type="text" value="<? echo $_POST['data']['reference_no'] ?>" readonly/></td>
        </tr>
        <tr>
            <td>Amount:&nbsp;</td><td><input name="amount" type="text" value="<? echo $_POST['data']['amount'] ?>"  readonly/>Rs.</td>
        </tr>
    </table>
    <input name="description" type="hidden" value="<? echo $_POST['description'] ?>" />

    <input name="name" type="hidden" value="<? echo $_POST['name'] ?>" />
    <input name="email" type="hidden" value="<? echo $_POST['email'] ?>" />
    <input name="phone" type="hidden" value="<? echo $_POST['phone'] ?>" />
    <input name="address" type="hidden" value="<? echo $_POST['address'] ?>" />
    <input name="country" type="hidden" value="IND" />
    <input name="postal_code" type="hidden" value="<? echo $_POST['postal'] ?>" />
    <input name="state" type="hidden" value="<? echo $_POST['state'] ?>" />
    <input name="city" type="hidden" value="<? echo $_POST['city'] ?>" />

    <input name="secure_hash" type="hidden" size="60" value="<? echo $secure_hash;?>" />
    <br/><br/><br/><input name="submit" value="Submit" type="submit" id="submit" style="background:#ff6600;color:#fff;height:40px;width:150px;font-family:Calibri;font-size: 22px;"/>
</form>

1 个答案:

答案 0 :(得分:1)

您必须再次检查表单定义。

删除onload事件声明。

<form method="post" action="https://secure.ebs.in/pg/ma/sale/pay" name="frmTransaction" id="frmTransaction" onSubmit="return validate()">