如果条件如何调用对话框? JavaScript的 [英] How to call dialog box inside if condition ? javascript
本文介绍了如果条件如何调用对话框? JavaScript的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这对于那些人来说是一个非常简单的问题,但我是初学者,我试图弄清楚如何在if条件中使用带有参数的2个按钮来调用对话框。我的代码不是调用函数只显示警报消息。如果有人可以开导,我会非常感谢谢谢
我尝试过:
I know this is a very simple question for those but I am a beginner and I am trying to figure out how to call dialog box with 2 buttons with parameters inside an if condition. my code is not calling function only display alert message. If someone can enlighten I will really appreciate it thank you
What I have tried:
<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>
推荐答案
(textfield1 + val1 +textfield2中存在,文本3中对应的值为+ val3.dialog({
buttons:{
Apply:function(){alert('you yes yes') ;},
取消:function(){
dialog.dialog('close');
}
}
});
}
< / script>
("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>
查阅文档以了解如何使用对话框< br $>
Dialog Widget | jQuery UI 1.10文档 [ ^ ]
从简单示例开始,让它工作,然后根据您的要求进行调整。
你不做var dialog =,你只需直接调用对话框方法,然后删除var dialog =位。其次,括号中的位是页面上元素的选择器,表示要显示的对话框。你的代码是这个
Consult the documentation to see how to use dialog
Dialog Widget | jQuery UI 1.10 Documentation[^]
Start with the simple example, get it working, then adapt it to your requirements.
You don't do "var dialog=", you just call the dialog method directly so drop the "var dialog=" bit. Secondly the bit in the parenthesis is a selector to an element on the page that represents the dialog you want to show. Your code is this
(textfield1+ val1 +存在于textfield2及其中文本3中的对应值是+ val3
("textfield1 " + val1 + " Exists in textfield2 and its corresponding value in text 3 is " + val3)
这不会选择任何项目。你需要一个像对话ID一样的div
That doesn't select any item. You need something like a div with an id of dialog
<div id="dialog" title="Dialog Title">I'm a dialog</div>
然后你做了类似的事情
Then you do something like
function stayonPage1(val1, val2, val3) {
这篇关于如果条件如何调用对话框? JavaScript的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文