function deleteChecked(){
var allValue="";
var j=0;
for(var i=0;i<document.allContacts.id.length;i++){
if(document.allContacts.id[i].checked===true){
j++;
allValue=document.allContacts.id[i].value+","+allValue;
}
} if(j<document.allContacts.id.length){
var conf=confirm("Are you sure to delete these Contacts?");
if(conf=="true")
window.open("http://127.0.0.1:8080/MiniContact/delete?id="+allValue);
}
else{
var conf=confirm("Are you sure to delete all Contacts?");
if(conf=="true")
window.open("http://127.0.0.1:8080/MiniContact/delete?id=all");
}
}
我想用JS来实现,我点击按钮触发上面的事件,方法可以执行,但是页面没动,是不是代码问题?应该怎么把页面转向SERVLET,或JSP
var allValue="";
var j=0;
for(var i=0;i<document.allContacts.id.length;i++){
if(document.allContacts.id[i].checked===true){
j++;
allValue=document.allContacts.id[i].value+","+allValue;
}
} if(j<document.allContacts.id.length){
var conf=confirm("Are you sure to delete these Contacts?");
if(conf=="true")
window.open("http://127.0.0.1:8080/MiniContact/delete?id="+allValue);
}
else{
var conf=confirm("Are you sure to delete all Contacts?");
if(conf=="true")
window.open("http://127.0.0.1:8080/MiniContact/delete?id=all");
}
}
我想用JS来实现,我点击按钮触发上面的事件,方法可以执行,但是页面没动,是不是代码问题?应该怎么把页面转向SERVLET,或JSP
var allValue="";
var j=0;
for(var i=0;i<document.allContacts.id.length;i++){
if(document.allContacts.id[i].checked===true){
j++;
allValue=document.allContacts.id[i].value+","+allValue;
}
} if(j<document.allContacts.id.length){
var conf=confirm("Are you sure to delete these Contacts?");
if(conf=="true")
document.formname.action ="/delete?id="+allValue";
document.formname.submit();
}
else{
var conf=confirm("Are you sure to delete all Contacts?");
if(conf=="true")
document.formname.action ="/delete?id=all");
document.formname.submit();
}
}
还有,跳转应该是window.location