隨筆 - 23  文章 - 3  trackbacks - 0
          <2006年4月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          常用鏈接

          留言簿(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
          靠,問的是怎么在方法之間傳遞對象。  回復  更多評論
            

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


          網站導航:
           
          主站蜘蛛池模板: 青神县| 江华| 花莲县| 西平县| 垣曲县| 达孜县| 永平县| 石楼县| 双流县| 沧源| 武安市| 固始县| 合水县| 贺兰县| 南部县| 诸城市| 北海市| 新泰市| 康定县| 樟树市| 天台县| 柯坪县| 来宾市| 东山县| 商城县| 南通市| 蒲城县| 资兴市| 延寿县| 尼木县| 栖霞市| 通江县| 唐海县| 靖宇县| 易门县| 武安市| 桓仁| 石台县| 江山市| 偃师市| 南澳县|