随笔 - 23  文章 - 3  trackbacks - 0
<2008年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

常用链接

留言簿(1)

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

<%@ 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>
注意点:
1、双引号里面只能含单引号
2、只有一个对象时,只能用getElementbyId(当id属性没有赋值时,name可以当作id属性),如果是一个数组对象,就要用getElementsByName.比较下面的文件:
function selectAll(obj,flag) {
 if(!obj) {//对象可以是null,但单个对象没有length的属性,所以还要判断length
  return false; 
 }
 if(!obj.length) {//如果是单个对象,不是对象数组
  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>
注意点:<%变量%>直接放在“”字符串内,不用连接“+<%变量%>+”
错误做法:<a href="http://localhost:8080/myRegister/myRegister.do?method=listRegister&&size="+<%=support.getPageSize()%>+"&&Page="+<%=support.getPreviousIndex()%>">上一页</a>
3.区别页面的跳转:
定向到其他页面
<script>
location.href("http://localhost:8080/new-register.jsp");
</script>
相当与<%response.sendRedirect("http://localhost:8080/new-register.jsp")%>
而windows.open(“http://localhost:8080/new-register.jsp”)则开出另一个窗口

posted on 2006-04-13 12:52 aimy 阅读(3649) 评论(2)  编辑  收藏

FeedBack:
# re: 4.13 javascript的对象传递  2007-07-06 16:00 大灰狼
javascript确实博大精深,值得深入研究一下~  回复  更多评论
  
# re: 4.13 javascript的对象传递  2008-07-02 17:35 11
靠,问的是怎么在方法之间传递对象。  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: