//简单的confirm改为用Jconfirm调用。content为内容,fn函数为确定按钮后所要执行的操作,fn_cbtn为取消按钮所要执行的操作(可以不填),tit为标题可以不填
//如果自己传确定函数则函数最后面要加D.J.dialog.inwin['c'].cancel();或者J.dialog.inwin['c'].cancel();把确定框关闭。
function Jconfirm(type,content,fn,fn_cbtn,tit,parent){
var title = '温馨提示';
var tempJ = J;//默认J对话框对象
var html = '<p align="center" style="_margin-top:10px;"><img src="'+sSystemPath+'images/alert/info.gif" align="absmiddle"> ' + content + '</p>';
if(type == 1) {
html = '<p align="center" style="_margin-top:10px;"><img src="'+sSystemPath+'images/alert/ask.gif" align="absmiddle"> ' + content + '</p>';
} else if (type == 2) {
html = '<p align="center" style="_margin-top:10px;"><img src="'+sSystemPath+'images/alert/right.gif" align="absmiddle"> ' + content + '</p>';
} else if (type == 3) {
html = '<p align="center" style="_margin-top:10px;"><img src="'+sSystemPath+'images/alert/err.gif" align="absmiddle"> ' + content + '</p>';
}
if( typeof(tit) != 'undefined' && tit != '') {
title = tit;
}
var height = 140;
var width = 100 + content.length*12;
width = width < 250 ? 250 : width;
if(width > 450){
width = 450;
height = 160;
}
if(typeof(parent) !== 'undefined' && parent != ''){
tempJ = parent.J
}
try {
var dlg = new tempJ.dialog({
id:'c', title:title, width:width, height:height, html:html, rang:true, cover:true,
iconTitle:false
});
dlg.ShowDialog();
if(typeof(fn_cbtn) !== 'undefined' && typeof(fn_cbtn)=="function"){
dlg.addBtn('ok', '取 消', fn_cbtn);
}
dlg.addBtn('ok', '确 定', function(){(fn)();dlg.cancel();});
} catch (oError) {
alert('没有引入lhgdialog脚本,不能调用Jalert');
}
}我在edit.jsp 和list.jsp页面各写了一个作废和删除一条记录的按钮,都调用了上面的方法,为什么在list页面中可以点击确定或者是取消,而在edit页面中那个提示窗口却一闪而过呢?也就是说它就默认执行确定按钮了, //作废 edit中的方法
function onCancelInfoCard(){
document.all("formaction").value ="edit_cancle";
document.all("unid").value = '<%=unid%>';
//Jconfirm方法 中参数 content为内容,fn函数为确定按钮后所要执行的操作,fn_cbtn为取消按钮所要执行的操作(可以不填),tit为标题可以不填
Jconfirm('1','您确定要将该记录作废 吗?',function(){document.forms["moduleForm"].submit();},'','','');
parent.$("#btn-Confirm").btn().disable();
document.all.editform.submit();
}//删除一条
function onDeleteByUnid(unid) {
document.all("formaction").value = "list_delete_by_unid";
document.all("unid").value = unid;
//doDelete方法的第一个参数是有选中项时的提示信息,第二个参数是都没选中时的提示信息。
//Jalert("您是否确定删除该信吗?","请您选择最少一行进行删除操作!");
Jconfirm('1','您确定删除该信吗?',function(){ document.forms["moduleForm"].submit();},'','');
}
//如果自己传确定函数则函数最后面要加D.J.dialog.inwin['c'].cancel();或者J.dialog.inwin['c'].cancel();把确定框关闭。
function Jconfirm(type,content,fn,fn_cbtn,tit,parent){
var title = '温馨提示';
var tempJ = J;//默认J对话框对象
var html = '<p align="center" style="_margin-top:10px;"><img src="'+sSystemPath+'images/alert/info.gif" align="absmiddle"> ' + content + '</p>';
if(type == 1) {
html = '<p align="center" style="_margin-top:10px;"><img src="'+sSystemPath+'images/alert/ask.gif" align="absmiddle"> ' + content + '</p>';
} else if (type == 2) {
html = '<p align="center" style="_margin-top:10px;"><img src="'+sSystemPath+'images/alert/right.gif" align="absmiddle"> ' + content + '</p>';
} else if (type == 3) {
html = '<p align="center" style="_margin-top:10px;"><img src="'+sSystemPath+'images/alert/err.gif" align="absmiddle"> ' + content + '</p>';
}
if( typeof(tit) != 'undefined' && tit != '') {
title = tit;
}
var height = 140;
var width = 100 + content.length*12;
width = width < 250 ? 250 : width;
if(width > 450){
width = 450;
height = 160;
}
if(typeof(parent) !== 'undefined' && parent != ''){
tempJ = parent.J
}
try {
var dlg = new tempJ.dialog({
id:'c', title:title, width:width, height:height, html:html, rang:true, cover:true,
iconTitle:false
});
dlg.ShowDialog();
if(typeof(fn_cbtn) !== 'undefined' && typeof(fn_cbtn)=="function"){
dlg.addBtn('ok', '取 消', fn_cbtn);
}
dlg.addBtn('ok', '确 定', function(){(fn)();dlg.cancel();});
} catch (oError) {
alert('没有引入lhgdialog脚本,不能调用Jalert');
}
}我在edit.jsp 和list.jsp页面各写了一个作废和删除一条记录的按钮,都调用了上面的方法,为什么在list页面中可以点击确定或者是取消,而在edit页面中那个提示窗口却一闪而过呢?也就是说它就默认执行确定按钮了, //作废 edit中的方法
function onCancelInfoCard(){
document.all("formaction").value ="edit_cancle";
document.all("unid").value = '<%=unid%>';
//Jconfirm方法 中参数 content为内容,fn函数为确定按钮后所要执行的操作,fn_cbtn为取消按钮所要执行的操作(可以不填),tit为标题可以不填
Jconfirm('1','您确定要将该记录作废 吗?',function(){document.forms["moduleForm"].submit();},'','','');
parent.$("#btn-Confirm").btn().disable();
document.all.editform.submit();
}//删除一条
function onDeleteByUnid(unid) {
document.all("formaction").value = "list_delete_by_unid";
document.all("unid").value = unid;
//doDelete方法的第一个参数是有选中项时的提示信息,第二个参数是都没选中时的提示信息。
//Jalert("您是否确定删除该信吗?","请您选择最少一行进行删除操作!");
Jconfirm('1','您确定删除该信吗?',function(){ document.forms["moduleForm"].submit();},'','');
}
这句话的含义我也没搞懂,所以位置都放错了。还是很感谢你哈!能抽时间来看我写的那么乱的问题~~~~~~~//作废
function onCancelInfoCard(){
document.all("formaction").value ="edit_cancle";
document.all("unid").value = '<%=unid%>';
//Jconfirm方法 中参数 content为内容,fn函数为确定按钮后所要执行的操作,fn_cbtn为取消按钮所要执行的操作(可以不填),tit为标题可以不填
Jconfirm('1','您确定要将该记录作废 吗?',function(){document.forms["moduleForm"].submit();},'','');
parent.$("#btn-Confirm").btn().disable();
document.all.editform.submit();
}
上面的是错误的,方法放的位置不对
下面是正确的://作废
function onCancelInfoCard(){
document.all("formaction").value ="edit_cancle";
document.all("unid").value = '<%=unid%>';
//Jconfirm方法 中参数 content为内容,fn函数为确定按钮后所要执行的操作,fn_cbtn为取消按钮所要执行的操作(可以不填),tit为标题可以不填
Jconfirm('1','您确定要将该记录作废 吗?',function(){
parent.$("#btn-Confirm").btn().disable();//若按了确定按钮,则使确定按钮无效,以免重复按
document.all.editform.submit();
},'','','');
}