我知道这对你们所有人来说是一个非常简单的问题,但我是一个初学者,我正在试图弄清楚,如何在条件语句中调用带有两个按钮和参数的对话框。我的代码没有调用该函数。它只显示一条警告消息。如果有人能开导我的错误,我将不胜感激谢谢。
<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>
发布于 2018-10-12 13:19:29
你可以在使用两个按钮的地方使用确认框。
<!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 >
https://stackoverflow.com/questions/52769472
复制相似问题