<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<script>
???? function checkall(all,one)
{
??? var obj = document.getElementsByName(one);
?? ?
??? if(!obj) return false;
??? if(!obj.length&&all.checked) return obj;
??? for(var i=0;i<obj.length;i++)
??? ?{
??? ??alert(all.checked);
??? ??obj[i].checked=all.checked
??? ??alert(obj[i].checked);
??? ?}
??? return true;
??
}?
???? function checkone(obj)
{
?alert('hello');
?alert(obj.name);
?return false;
}
?</script>
</head>
<body bgcolor="#ffffff">
?<form>
??<input type="checkbox" onclick="return checkone(this)" name="mm"/><br>//有return,無法選擇這個checkbox
??<input type="checkbox" onclick="checkone(this)" name="mm"/><br>//無論是否返回false,都可以選擇這個checkbox
??<input type="checkbox" onclick="checkone(this)" name="mm"/><br>
??????? <input type="checkbox" onclick="checkall(this,'mm')" name="mmAll"/><br>
?? ?
??? </form>
<table border="0">
</table>
</body>
</html>
注意點(diǎn):
1、雙引號里面只能含單引號
2、只有一個對象時,只能用getElementbyId(當(dāng)id屬性沒有賦值時,name可以當(dāng)作id屬性),如果是一個數(shù)組對象,就要用getElementsByName.比較下面的文件:
function selectAll(obj,flag) {
?if(!obj) {//對象可以是null,但單個對象沒有l(wèi)ength的屬性,所以還要判斷l(xiāng)ength
??return false;?
?}
?if(!obj.length) {//如果是單個對象,不是對象數(shù)組
??obj.checked=true;
??return true;
?}
?for(var i=0;i<obj.length;i++) {
??obj[i].checked=flag;
?}
?return true;?
}
/**
* Test selected one item or not
* @author rainshow
*/
function selectOne(obj) {
?if(!obj) {
??return false;
?}
?if(!obj.length&&obj.checked) {
??return obj;
?}
?var count=0;
?var checkedObj;
?for(var i=0;i<obj.length;i++) {
??if(obj[i].checked) {
???checkedObj=obj[i];
???count++;
??}
?}
?if(count==1) {
??return checkedObj;
?}
?return false;
}
2。<a href="http://localhost:8080/myRegister/myRegister.do?method=listRegister&&size=<%=support.getPageSize()%>&&Page=<%=support.getPreviousIndex()%>">上一頁</a>
注意點(diǎn):<%變量%>直接放在“”字符串內(nèi),不用連接“+<%變量%>+”
錯誤做法:<a href="http://localhost:8080/myRegister/myRegister.do?method=listRegister&&size="+<%=support.getPageSize()%>+"&&Page="+<%=support.getPreviousIndex()%>">上一頁</a>
3.區(qū)別頁面的跳轉(zhuǎn):
定向到其他頁面
<script>
location.href("http://localhost:8080/new-register.jsp");
</script>
相當(dāng)與<%response.sendRedirect("http://localhost:8080/new-register.jsp")%>
而windows.open(“http://localhost:8080/new-register.jsp”)則開出另一個窗口