隨筆 - 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 閱讀(3659) 評論(2)  編輯  收藏

          FeedBack:
          # re: 4.13 javascript的對象傳遞  2007-07-06 16:00 大灰狼
          javascript確實博大精深,值得深入研究一下~  回復  更多評論
            
          # re: 4.13 javascript的對象傳遞  2008-07-02 17:35 11
          靠,問的是怎么在方法之間傳遞對象。  回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 德庆县| 湟源县| 平原县| 琼结县| 凤山县| 雷州市| 江源县| 上思县| 昌平区| 安多县| 镶黄旗| 招远市| 团风县| 宜城市| 内江市| 永顺县| 湄潭县| 壤塘县| 蒲江县| 夏津县| 临江市| 鄂托克旗| 英吉沙县| 定边县| 衡南县| 赣榆县| 临泽县| 临高县| 东山县| 广平县| 囊谦县| 恩平市| 灵丘县| 景泰县| 白城市| 枣庄市| 广东省| 托里县| 棋牌| 博白县| 大理市|