我通过按ID单击按钮来运行此脚本。我想使用onclick函数来运行此脚本不起作用。
<button id="rzp-button1" onclick=ShowCal()>Pay</button>
我有一个onclick函数来调用此脚本不起作用,请帮助
<script>
function ShowCal() {
var options = {
"key": "rzp_test_jzLFENHc7oM",
"amount": "<%=Session["payment"]%>", /// The amount is shown in currency subunits. Actual amount is ₹599.
"name": "New tech",
"order_id": "<%=Session["orderId"]%>", // Pass the order ID if you are using Razorpay Orders.
"currency": "INR" ,// Optional. Same as the Order currency
"description": "",
"image": "images/new.png",
"handler": function (response){
alert(response.razorpay_order_id);
},
p1 = new Razorpay(options);
document.getElementById('rzp-button1').onclick = function (e)
{
rzp1.open();
e.preventDefault();
}
}
</script>
答案 0 :(得分:0)
function ShowCal() {
var options = {
"key": "rzp_test_jzLFENHc7oM",
"amount": "<%=Session["+ payment +"]%>",
"name": "New tech",
"order_id": "<%=Session["+ orderId +"]%>",
"currency": "INR",
"description": "",
"image": "images/new.png",
"handler": function (response) {
alert(response.razorpay_order_id);
}
}
p1 = new Razorpay(options);
document.getElementById('rzp-button1').onclick = function (e){
e.preventDefault();
rzp1.open();
}
}