JSfunction delete(name){var ok=confirm("Delete contact"+name);
if(ok==false)
return false;
else
return true;
}function checkAll(){
for(var i=0;i<document.all.id.length;i++){
document.all.id[i].checked=true;
}
}
//////////////////////////////////////////
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width="90%" height="600">
<tr>
<td align="center" width="12%">PB HOME</td>
<td align="center" >
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width="95%">
<tr bgcolor="#cccccc">
<th width="48" height="38" >Check Box</th>
<th width="105" >Name</th>
<th width="119">Mobile</th>
<th width="110">Home</th>
<th width="119">Office</th>
<th width="128" >Action</th>
</tr>
<#list list as contact>
<tr>
<td><input type="checkbox" name="id" value="${contact.id}"></td>
<td><input type="hidden" name="name" value="${contact.name}">${contact.name}</td>
<td>${contact.mobile}</td>
<td>${contact.home}</td>
<td>${contact.office}</td>
<td>
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width=100%>
<tr>
<td><a href="/MiniContact/detail?id=${contact.id}">Detail</a></td>
<td><a href="/MiniContact/detail?idd=${contact.id}" >Edit</a></td>
<td><a onClick="delete(${contact.name})" href="/MiniContact/delete?id=${contact.id}">Delete</a></td>//在此为何不执行JS方法 而直接跳转</tr>
</table>
</td>
</tr>
</#list>
<td height="64">
<tr>
<td height="59" colspan="6" align="center">
<table border="1" cellspacing="0" width="100%">
<tr>
<td><a href="ShowAllContact.ftl" onClick="checkAll()">Check All</a></td>//在此也不执行JS方法!
<td><input type="button" onClick="deleteAll()" value="Delete Checked"></td>
<td><a href="/MiniContact/addContact.ftl">Add Contact</a></td>
</tr>
</table>
if(ok==false)
return false;
else
return true;
}function checkAll(){
for(var i=0;i<document.all.id.length;i++){
document.all.id[i].checked=true;
}
}
//////////////////////////////////////////
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width="90%" height="600">
<tr>
<td align="center" width="12%">PB HOME</td>
<td align="center" >
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width="95%">
<tr bgcolor="#cccccc">
<th width="48" height="38" >Check Box</th>
<th width="105" >Name</th>
<th width="119">Mobile</th>
<th width="110">Home</th>
<th width="119">Office</th>
<th width="128" >Action</th>
</tr>
<#list list as contact>
<tr>
<td><input type="checkbox" name="id" value="${contact.id}"></td>
<td><input type="hidden" name="name" value="${contact.name}">${contact.name}</td>
<td>${contact.mobile}</td>
<td>${contact.home}</td>
<td>${contact.office}</td>
<td>
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width=100%>
<tr>
<td><a href="/MiniContact/detail?id=${contact.id}">Detail</a></td>
<td><a href="/MiniContact/detail?idd=${contact.id}" >Edit</a></td>
<td><a onClick="delete(${contact.name})" href="/MiniContact/delete?id=${contact.id}">Delete</a></td>//在此为何不执行JS方法 而直接跳转</tr>
</table>
</td>
</tr>
</#list>
<td height="64">
<tr>
<td height="59" colspan="6" align="center">
<table border="1" cellspacing="0" width="100%">
<tr>
<td><a href="ShowAllContact.ftl" onClick="checkAll()">Check All</a></td>//在此也不执行JS方法!
<td><input type="button" onClick="deleteAll()" value="Delete Checked"></td>
<td><a href="/MiniContact/addContact.ftl">Add Contact</a></td>
</tr>
</table>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
td{text-align:center;}
th{text-align:center;}
</style><script type="text/javascript">
function deleteAll(){
var allValue="";
var count=0;
for(var i=0;i<document.all.id.length;i++){
if(document.all.id[i].checked==true)
allValue+=document.all.id[i].value+",";
while(count==document.all.id.length){
var confirm=confirm("Are you sure to delete all Contacts?");
if(confirm=="true")
window.open("/MiniContact/delete?id=all");
break;
}
count++;
}
var confirm=confirm("Are you sure to delete these Contacts?");
if(comfirm=="true")
window.open("/MiniContact/delete?id="+allValue);
}function delete(name){var ok=confirm("Delete contact"+name);
if(ok==false)
return false;
else
return true;
}
function checkAll(){
for(var i=0;i<document.all.id.length;i++){
document.all.id[i].checked=true;
}
}
</script><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Show All Contact</title>
</head>
<body>
<center>
<br>
<br>
<br>
<h2>OPERATOR SPECIFIC CUSTOMIZATION</h2>
<hr noshade>
<form>
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width="90%" height="600">
<tr>
<td align="center" width="12%">PB HOME</td>
<td align="center" >
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width="95%">
<tr bgcolor="#cccccc">
<th width="48" height="38" >Check Box</th>
<th width="105" >Name</th>
<th width="119">Mobile</th>
<th width="110">Home</th>
<th width="119">Office</th>
<th width="128" >Action</th>
</tr>
<#list list as contact>
<tr>
<td><input type="checkbox" name="id" value="${contact.id}"></td>
<td><input type="hidden" name="name" value="${contact.name}">${contact.name}</td>
<td>${contact.mobile}</td>
<td>${contact.home}</td>
<td>${contact.office}</td>
<td>
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width=100%>
<tr>
<td><a href="/MiniContact/detail?id=${contact.id}">Detail</a></td>
<td><a href="/MiniContact/detail?idd=${contact.id}" >Edit</a></td>
<td><a onClick="delete(${contact.name})" href="/MiniContact/delete?id=${contact.id}" >Delete</a></td>
</tr>
</table>
</td>
</tr>
</#list>
<td height="64">
<tr>
<td height="59" colspan="6" align="center">
<table border="1" cellspacing="0" width="100%">
<tr>
<td><a href="ShowAllContact.ftl" onClick="checkAll()">Check All</a></td>
<td><input type="button" onClick="deleteAll()" value="Delete Checked"></td>
<td><a href="/MiniContact/addContact.ftl">Add Contact</a></td>
</tr>
</table>
</tr>
<tr>
<td align="center" colspan="6"><a href="/MiniContact/search.ftl">Search</a></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
我的FreeMarker 不是JSP
不过和这个没多少关系!
希望大家多帮忙 我的JS很差
扔进去看看执行么<td> <a href="ShowAllContact.ftl" onClick="checkAll()"> Check All </a> </td>
<td> <input type="button" onClick="deleteAll()" value="Delete Checked"> </td>
难道deleteAll()执行的checkAll()就不执行?
太诡异了巴
都不执行 我只是着重的突出checkAll() 呵呵
代码有问题吗?还有
td> <a onClick="delete(${contact.name})" href="/MiniContact/delete?id=${contact.id}"> Delete </a> </td>
这句为什么不执行JS呢?放了 alert();没反应!
如 onClick="deleteAll()" 应该为 onClick="deleteAll();" 。不知道说的对不对,呵呵。见谅!
<a onClick="delete(${contact.name})" href="/MiniContact/delete?id=${contact.id}">Delete</a>这个会执行的。
顺便说一下,为什么你发代码不用CSDN的代码高亮呢?这样的代码贴出来看都懒的看了,一点格式都没有
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
td{text-align:center;}
th{text-align:center;}
</style> <script type="text/javascript">
function deleteAll(){
var allValue="";
var count=0;
for(var i=0;i <document.all.id.length;i++){ if(document.all.id[i].checked==true)
allValue+=document.all.id[i].value+","; while(count==document.all.id.length){
var confirm=confirm("Are you sure to delete all Contacts?");
if(confirm=="true")
window.open("/MiniContact/delete?id=all");
break;
}
count++;
}
var confirm=confirm("Are you sure to delete these Contacts?");
if(comfirm=="true")
window.open("/MiniContact/delete?id="+allValue);
}
function delete(name){ var ok=confirm("Delete contact"+name);
if(ok==false)
return false;
else
return true;
}
function checkAll(){
for(var i=0;i <document.all.id.length;i++){
document.all.id[i].checked=true;
}
}
</script> <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> Show All Contact </title>
</head>
<body>
<center>
<br>
<br>
<br>
<h2> OPERATOR SPECIFIC CUSTOMIZATION </h2>
<hr noshade>
<form>
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width="90%" height="600">
<tr>
<td align="center" width="12%"> PB HOME </td>
<td align="center" >
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width="95%">
<tr bgcolor="#cccccc">
<th width="48" height="38" > Check Box </th>
<th width="105" > Name </th>
<th width="119"> Mobile </th>
<th width="110"> Home </th>
<th width="119"> Office </th>
<th width="128" > Action </th>
</tr>
<#list list as contact>
<tr>
<td> <input type="checkbox" name="id" value="${contact.id}"> </td>
<td> <input type="hidden" name="name" value="${contact.name}"> ${contact.name} </td>
<td> ${contact.mobile} </td>
<td> ${contact.home} </td>
<td> ${contact.office} </td>
<td>
<table border="1" bordercolordark="#000000" bordercolorlight="#000000" width=100%>
<tr>
<td> <a href="/MiniContact/detail?id=${contact.id}"> Detail </a> </td>
<td> <a href="/MiniContact/detail?idd=${contact.id}" > Edit </a> </td>
<td> <a onClick="delete(${contact.name})" href="/MiniContact/delete?id=${contact.id}" > Delete </a> </td>
</tr>
</table>
</td>
</tr>
</#list>
<td height="64">
<tr>
<td height="59" colspan="6" align="center">
<table border="1" cellspacing="0" width="100%">
<tr>
<td> <a href="ShowAllContact.ftl" onClick="checkAll()"> Check All </a> </td>
<td> <input type="button" onClick="deleteAll()" value="Delete Checked"> </td>
<td> <a href="/MiniContact/addContact.ftl"> Add Contact </a> </td>
</tr>
</table>
</tr>
<tr>
<td align="center" colspan="6"> <a href="/MiniContact/search.ftl"> Search </a> </td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
如
delete(), confirm关键字 etc
谢谢大家