为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 sweetalert 中采取两个选项并根据该选项采取行动?

如何在 sweetalert 中采取两个选项并根据该选项采取行动?

四季花海 2022-01-13 15:04:40
我有一个只需要Ok和 的 Sweetalert Cancle。如果ok它根据那个执行选项。我需要两个选项:With Payment和Without Payment. 如果用户选择With Payment,它将要求用户输入金额并将其发送到另一个页面。我当前的order.list.js页面是这样的function completeOrder(orderID) {  var obj = {    order: order,    page: page,    customer: $("#customers_" + from).val(),    sdate: $("#sdate_" + from).val(),    edate: $("#edate_" + from).val(),    Status: Status  };  swal({    title: "Are you sure?",    text: "You want to complete this order Without Payment !!",    icon: "warning",    buttons: true,    dangerMode: true,  }).then((willDelete) => {    if (willDelete) {      $.ajax({        url: "process/order-process.php",        type: "POST",        data: {          orderID: orderID,          status: "Completed",          payment: "Not Paid"        },        beforeSend: function() {},        success: function(response) {          if (response.indexOf("success") >= 0) {            swal("Good job! Your order has been completed!", {              icon: "success",            });            getResult(true, 'process/order-list.php', "POST", JSON.stringify(obj), from);          } else {            swal("Error!", "Something went wrong!", "error");          }        }      });    } else {}  });}
查看完整描述

1 回答

?
蝴蝶刀刀

TA贡献1801条经验 获得超8个赞

你有没有尝试过下面这样的事情


swal("Place the order?", {

    title: "Are you sure?",

    text: "You want to complete this order Without Payment !!",

    icon: "warning",

    buttons: {

        withPayment: "With Payment",

        withOutPayment: "With out Payment",

    }

})

.then((value) => {

    switch (value) {


        case "withPayment":

            // Proceed with payment

            break;


        case "withOutPayment":

            // Proceed without payment

            break;

    }

});


查看完整回答
反对 回复 2022-01-13
  • 1 回答
  • 0 关注
  • 103 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信