首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >功能对话框2按钮不在状态下工作

功能对话框2按钮不在状态下工作
EN

Stack Overflow用户
提问于 2018-10-12 05:58:13
回答 1查看 21关注 0票数 1

我知道这对你们所有人来说是一个非常简单的问题,但我是一个初学者,我正在试图弄清楚,如何在条件语句中调用带有两个按钮和参数的对话框。我的代码没有调用该函数。它只显示一条警告消息。如果有人能开导我的错误,我将不胜感激谢谢。

代码语言:javascript
运行
复制
<div id="requirement #2">

  <button type="button" id="button4" onclick="StringSearch1()">Search</button>
</div>
<script>
 function StringSearch1() {
        if (condition) {

           stayonPage1(val1,val2,val3);
          //  alert("textfield1 " + val1 + " Exists in textfield2 and its corresponding value in text 3 is " + val3);
           //the alert message is working but I want to call the function dialogbox  to pop
        } else {
           //  alert("textfield1 " + val1 + " not Exists in textfield2 and its corresponding value in text 3 is " + val3)
        }
    }
      function stayonPage1(val1,val2,val3){
     var dialog = $("textfield1 " + val1 + " Exists in textfield2 and its corresponding value in text 3 is " + val3).dialog({
            buttons: {
                "Apply": function() {alert('you chose yes');},

                "Cancel":  function() {
                    dialog.dialog('close');
                }
            }
     });

        }

    </script>
EN

回答 1

Stack Overflow用户

发布于 2018-10-12 13:19:29

你可以在使用两个按钮的地方使用确认框。

代码语言:javascript
运行
复制
<!DOCTYPE HTML>
<html>
<head>
    
    <style>
       
    </style>
 </head >

<body>


    <div id="requirement #2">

        <button type="button" id="button4" onclick="StringSearch1()">Search</button>
    </div>


   
    <script>


        function StringSearch1() {
            var condition = true;
            var val1 = '1', val2 = '2', val3 = '3';
            if (condition) {

                stayonPage1(val1, val2, val3);
              


            } else {
                
            }
        }
        function stayonPage1(val1, val2, val3) {

            var Val = confirm("textfield1 " + val1 + " Exists in textfield2 and its corresponding value in text 3 is " + val3);
            if (Val == true) {
                alert('you chose yes');
                return true;
            }
            else {
                alert("close");
                return false;
            } 
            //var dialog = $("textfield1 " + val1 + " Exists in textfield2 and its corresponding value in text 3 is " + val3).dialog({
            //    buttons: {
            //        "Apply": function () { alert('you chose yes'); },

            //        "Cancel": function () {
            //            dialog.dialog('close');
            //        }
            //    }
            //});

        }

    </script>
</body>
 </html >

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52769472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档