【问题标题】:How to take two option in sweetalert and take action according to that option?如何在 sweetalert 中采取两个选项并根据该选项采取行动?
【发布时间】:2019-11-27 11:35:14
【问题描述】:

我有一个 Sweetalert,它只需要 OkCancle。如果ok 则根据它执行选项。

我需要两个选项:With PaymentWithout 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 {}
  });
}

【问题讨论】:

  • 请创建一个sn-p,以便我们为您提供帮助。 :)

标签: javascript php jquery css sweetalert


【解决方案1】:

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

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;
    }
});

【讨论】:

    猜你喜欢
    • 2010-11-24
    • 1970-01-01
    • 2012-09-15
    • 2018-12-25
    • 2017-01-20
    • 1970-01-01
    • 1970-01-01
    • 2013-09-01
    • 1970-01-01
    相关资源
    最近更新 更多