如何在第一次成功破坏时运行第二个JS函数 [英] How to run second JS function only when the first runed successfully
本文介绍了如何在第一次成功破坏时运行第二个JS函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程序中使用了以下代码,当用户单击是时显示验证屏幕,当用户单击取消时它还显示验证屏幕
i想要
i used the below code in my application,it show the authenticate screen when user click yes and it also shows authenticate screen when the user click cancel
i want the
authenticate
屏幕
我尝试过: < br $>
screen only when the user press yes
What I have tried:
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to Delete data?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
<li><asp:LinkButton ID="lnk_Delete" runat="server" OnClientClick="javascript:Confirm();javascript:return OpenSwipWindowAction('Delete','')"><img src="../images/Document_Delete.png" alt="" />Delete</asp:LinkButton></li>
Dim confirmValue As String
ElseIf hdnModuleName.Value = "Delete" Then
confirmValue = Request.Form("confirm_value")
If confirmValue = "Yes" Then
Label12.Text = "yes"
Else
Label12.Text = "No"
End If
推荐答案
我认为这是代码应该是什么样子
按钮点击提示确认
I think this is how the code should look like
On button click prompt confirm
<asp:LinkButton ID="lnk_Delete" runat="server"
OnClientClick="return Confirm();">
<img src="../images/Document_Delete.png" alt="" />Delete</asp:LinkButton>
如果是,请设置隐藏值和调用返回OpenSwipWindowAction(...)(假设它返回true | false)
else(取消),返回false,什么都不做(我假设)
If yes, set hidden value and call return OpenSwipWindowAction (...) (Assuming it return true | false)
else (Cancel), return false, do nothing ( I'm assuming )
<script>
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to Delete data?")) {
confirm_value.value = "Yes";
document.forms[0].appendChild(confirm_value);
return OpenSwipWindowAction('Delete', '');
} else {
confirm_value.value = "No";
return false;
}
document.forms[0].appendChild(confirm_value);
}
</script>
这篇关于如何在第一次成功破坏时运行第二个JS函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文