首页 > 解决方案 > 如何获取使用 sweetalert 输入的输入值?

问题描述

使用属性'类型:“输入”',我可以在文本框中输入值。我需要知道如何获取输入值。下面是我的代码:

输入:“文本”不起作用...我尝试使用 json.parse 获取值...没有任何效果。请帮我获取和存储价值

swal({ title: "Your order summary is ***", text: "Proceed to checkout", //type: "success", type: "input", showCancelButton: true, confirmButtonColor: "#EF5350", confirmButtonText: "是", cancelButtonText: "否", closeOnConfirm: false, showLoaderOnConfirm: false }, function(isConfirm){ if (isConfirm) { var gstva = jQuery.parseJSON(result); var dataString = {"pushCount":/ pushCount/0, "LECount":LECount,"gst": gstva}; $.ajax({ type:'POST', url: "store/requestPurchase", data: dataString, async: false, success: function(response){ var obj = jQuery.parseJSON(response); var response = obj.result ;

标签: sweetalertsweetalert2

解决方案


swal({
                        title: "Your order summary is - <?php echo $price->country_detail; ?> - "+totalCost+"/- + Taxes",
                        text: "Proceed to checkout",
                        type : "input",
                        inputPlaceholder: "Enter your GST number(optional)",
                        showCancelButton: true,
                        confirmButtonText: "Yes",
                        closeOnConfirm: false,
                },
                function(inputValue,isConfirm){
                    if (((inputValue === "") || (inputValue !== "")) && (inputValue !== false)){
                        var dataString = {"pushCount":0, "LECount":LECount, "gstValue":inputValue};

推荐阅读