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

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

          Posted on 2007-08-01 08:50 semovy 閱讀(1062) 評論(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>

           

          主站蜘蛛池模板: 清河县| 玉门市| 察雅县| 清丰县| 莱阳市| 开远市| 邹城市| 嘉峪关市| 泰安市| 扎囊县| 花莲县| 双辽市| 全南县| 东光县| 五台县| 高安市| 山东省| 陆河县| 吉水县| 平陆县| 新乐市| 房产| 庆城县| 监利县| 大丰市| 哈密市| 龙南县| 大港区| 林州市| 嘉义县| 浦江县| 防城港市| 东阿县| 墨玉县| 铁岭县| 南汇区| 资兴市| 拉孜县| 哈密市| 温宿县| 马公市|