posts - 0, comments - 77, trackbacks - 0, articles - 356
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          在Firefox下使用insertRow需要注意參數

          Posted on 2007-08-01 08:50 semovy 閱讀(1056) 評論(0)  編輯  收藏 所屬分類: JavaScript

          表格對象的方法有一個默認的參數-1,表示在當前行或者單元格后插入行和單元格。在ie中可以不用填寫這個參數,但是在瀏覽器下必須加上這個參數否則就會出現缺少參數的錯誤。



          <html>
          <head>
          <title>
          multiUploadDemo
          </title>
          </head>
          <script language="javascript">
             var num = 0;
           
           function upload(){
            document.getElementById("status").innerHTML = "文件上傳中...";
               multiUploadForm.submit();
             }

          function additem(id)
          {
           var row,cell,str;
           //row = eval("document.all["+'"'+id+'"'+"]").insertRow();
           row = document.getElementById(id).insertRow(-1); 
           if(row != null )
              {
                 cell = row.insertCell(-1);
                 str="<input type="+'"'+"file"+'"'+" name=uploadFile["+ num +"].file><input type="+'"'+"button"+'"'+" value="+'"'+"刪除"+'"'+" onclick='deleteitem(this,"+'"'+"tb"+'"'+");'>"
                cell.innerHTML=str;
              }
           num++;
          }
          function deleteitem(obj,id)
          {
           var rowNum,curRow;
           curRow = obj.parentNode.parentNode;
           //rowNum = eval("document.all."+id).rows.length - 1;
           rowNum = document.getElementById(id).rows.length - 1;
           document.getElementById(id).deleteRow(curRow.rowIndex);
           //eval("document.all["+'"'+id+'"'+"]").deleteRow(curRow.rowIndex);
          }
          function callback(msg)
          {
           document.getElementById("status").innerHTML = "文件上傳完成...<br>" + msg;
          }
          </script>
          <body bgcolor="#ffffff">
          <div id="status"></div>
          <html:form method="post" action="/multiUpload.do" enctype="multipart/form-data" target="hidden_frame">

          <table id="tb">
          </table>

          </html:form>
          <iframe name='hidden_frame' id="hidden_frame" style="display:none"></iframe>
          <input type="button" name="btnAddFile" value="Add File" onclick="additem('tb')"/>
          <input type="button" name="btnUpload" value="upload" onclick="upload()"/>
          </body>
          </html>

           

          主站蜘蛛池模板: 清徐县| 库伦旗| 临海市| 溧阳市| 从江县| 任丘市| 淄博市| 句容市| 鱼台县| 凤翔县| 吉木萨尔县| 如皋市| 达尔| 武隆县| 屏南县| 彭泽县| 石景山区| 博湖县| 乐昌市| 开鲁县| 珠海市| 阜康市| 德保县| 鸡泽县| 长宁县| 宝坻区| 全州县| 巴彦县| 金昌市| 曲沃县| 莱阳市| 云龙县| 屏东县| 富川| 黑河市| 台安县| 佛学| 甘肃省| 噶尔县| 平远县| 中山市|