[英]java script confirm box, it should remain on same page when cancel button is clicked
[英]Page should refresh when click cancel on confirm box
return confirm('Changing the protocol will reset the project Team members');
}
我将两种方法称为onclick,第一种是多次停止单击按钮,第二种是显示确认框。 用户单击取消后,用户将无法再次保存它。 我正在寻找解决方案以区分这两种肉类。
<apex:commandButton onclick=" this.onclick=function(){return false;}; return showProtocolEditWarning();" action="{!save}" value="Save" id="commandButtonSave"/>
function showProtocolEditWarning(){
if(projectId && praProtocol){
var newProject = document.querySelector('input[id$="inputFieldPraProject_lkid"]').value;
var protocolIdElement = document.querySelector('select[id$="protocolIdList"]');
var newProtocol = protocolIdElement.options[protocolIdElement.selectedIndex].value;
if(praProject.substring(0,15) != newProject.substring(0,15) || praProtocol != newProtocol){
return confirm('Changing the protocol will reset the project Team members');
//window.location.reload() ;
}
}
return true;
}
您应该检查用户单击了什么,而不是返回confirm(...)
,如果用户单击取消,请使用location.reload()
重新加载页面:
function confirmMessage() { if(confirm('Your confirmation msg')) { //ie if the user pressed ok //handle this } else { //ie user pressed cancel location.reload(); } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.