js 动态table

<html>
<head>
<title>add</title> 
<script>
<!--
var ListUtil = new Object(); 
ListUtil.add = function(oListbox,sName,sValue)
{
 var oOption = document.createElement("option");
 oOption.appendChild(document.createTextNode(sName)); 
 if(arguments.length == 3)
 {
  oOption.setAttribute("value",sValue);
 }
 oListbox.appendChild(oOption);
}


ListUtil.remove = function(oListbox,iIndex)
{
 oListbox.remove(iIndex);
}


ListUtil.clear = function(oListbox)
{
 for(var i = oListbox.options.length - 1; i>=0;i--)
 oListbox.remove(oListbox,i);  
}


function listRecordTime(timeData,type)// rcv a parameter ok 
{
 var first;
 var divs;
 
 if(type==1)
 {
   var oListbox = document.getElementById("avitable");
  ListUtil.add(oListbox,timeData,timeData);
 }
 else
 {
  var oListbox = document.getElementById("avListEnd");
  var oListbox2 = document.getElementById("avListStart"); 
  var obgDiv = document.getElementById("page");
  var tem = new Array();
  var tem2 = new Array();
  var first = new Array();
  
  first = timeData.split("|");
  var totallist=first[0];
  var currentpage=first[1]; 
  var globalPara2=first[2];
  
  //alert(timeData);
  if ((divs=(2*20)%totallist) > 0)
  {
   totalpages = totallist/(2*20); 
   //alert(totalpages);
  } 
  tem = globalPara2.split(";");
  
  ListUtil.clear(oListbox);
  ListUtil.clear(oListbox2);
  
  for(var j= 0; j< tem.length; j++)
  {
   tem2 = tem[j].split(",");
   for(var i= 0; i<tem2.length;i++)
   {
    if(i%2==0)
     ListUtil.add(oListbox2,tem2[i],tem2[i]);
    else    
     ListUtil.add(oListbox,tem2[i],tem2[i]);
   }  
  }
  var inHtml = genaratePageDiv(currentpage, totalpages);
  obgDiv.innerHTML=inHtml;  
  obgDiv.style.display="";  
  if (totalpages == 0)
  {
   document.getElementById("pre").disabled = true;
   document.getElementById("next").disabled = true;
  }
  if(currentpage==1)
   document.getElementById("pre").disabled = true;
  
  if(Math.ceil(totallist/eachpage)==currentpage)  
   document.getElementById("next").disabled = true;
  
  document.getElementById("record_button").style.display = "inline"; 
  } 
}


function genaratePageDiv(current, totalpages)
{
 var inHtml = "";  
 inHtml +="<input type='button' name='pre' value='prevpage' onClick='dividePage(("+current+"-1),"+eachpage+")'>&nbsp;&nbsp;"; 
 inHtml +="<input type='button' name='next' value='nextpage' onClick='dividePage(("+current+"+1),"+eachpage+")'>&nbsp;&nbsp;"; 
 inHtml +="<input type='button' name='clean' value='clear all' onClick='jsCtrlDevice(6,\"\")'>"; 
 return inHtml;


}


function dividePage(current,page)
{
 alert(current);
 alert(page);
 var timeData = Player.GetDeviceRecordList(current,page);
 listRecordTime(timeData,2);
 //listRecordTime("20|3|2005-09-19 12:56,2006-08-12 05:13");
}


function hiddenDiv(div_id){
   var obgDiv = document.getElementById(div_id);
   obgDiv.style.display="none";
}


var indx=0; 


function addTabRow(){    
 var schedule_tab = document.getElementById("mybody");    
 var schedule_tr = schedule_tab.insertRow();    
 schedule_tr.setAttribute("id","tr"+indx);   
  var scheduletd_1=schedule_tr.insertCell();    
  var scheduletd_2=schedule_tr.insertCell();    
  var scheduletd_3=schedule_tr.insertCell(); 
  var scheduletd_4=schedule_tr.insertCell();    
  var scheduletd_5=schedule_tr.insertCell(); 
  var scheduletd_6=schedule_tr.insertCell();     
 
   scheduletd_1.innerHTML=indx;    
   scheduletd_2.innerHTML="<input type='type' name='time"+indx+"' size='4' value=''/>";  
   scheduletd_3.innerHTML="<input type='radio' name='type"+indx+"' value='1' checked/>off_all<input type='radio' name='type"+indx+"' value='2'/>on_all<input type='radio' name='type"+indx+"' value='3'/>Shedule"; 
   indx+=1;   
   scheduletd_4.innerHTML=indx;    
   scheduletd_5.innerHTML="<input type='type' name='time"+indx+"' size='4' value='' />";  
   scheduletd_6.innerHTML="<input type='radio' name='type"+indx+"' value='1' checked/>off_all<input type='radio' name='type"+indx+"' value='2'/>on_all<input type='radio' name='type"+indx+"' value='3'/>Shedule";  
   indx+=1; 
 }    
   
function delTabRow(j){    
 var schedule_tab = document.getElementById("mybody");    
 var tabrow = document.getElementById("tr"+j);    
  schedule_tab.deleteRow(tabrow.rowIndex-1);    
 }   


function delAllTabRow(){    
 var schedule_tab = document.getElementById("mybody");    
 var rowlen=schedule_tab.rows.length;    
 for(var i=rowlen-1;i>=0;i--){    
   schedule_tab.deleteRow(i);    
  }
  indx = 0;    
 }   


// -->
</script>


</head>
<body bgcolor="white" leftmargin="15" topmargin="20"  onLoad="onLoad()" marginwidth="0" marginheight="0" class="bodyBg">


<form name="aviList">
 <input type="hidden" name="avi" value="">
</form>
<div id="gif" style="position:absolute; display:none; background:url(loading_32x32.gif) no-repeat; left: 50%; width: 100%; height: 100%"></div>
<div>
 <div>
 
 <form name="remote_playbk" id="1">
 <table>
   <tr valign=""><td class="subTitle" align="left" colspan="3"><u><h3><b>Remote AVI File List<br><br></b></h3></u></td></tr>
      <tr>
     <td valign="top">
   <div id="avi_download_table">     
    &nbsp;<span class="fixedTitle"><b><script>writeList(0,true);</script></b></span><br>
    <span class="fixed"><select class="fixed" style="width:310px" size="17" name="avitable" multiple οndblclick="ButtonPlay_onclick(this.value);">
    <script>writeList(0,false);</script></select></span>
    </div>
      <div id="div_time">
     <table>
    <tr>
     <td>
     <div>
      <span class="fixedTitle"><b><script>writeList(1,true);</script></b></span><br>
      <span class="fixed"><select class="fixed" style="width:150px" size="16" name="avListStart" multiple οndblclick="txTimeValue(this.value,1);">
      <script>writeList(1,false);</script></select></span>
     </div>
     </td>
     <td>
     <div>
      <span class="fixedTitle"><b><script>writeList(2,true);</script></b></span><br>
      <span class="fixed"><select class="fixed" style="width:150px" size="16" name="avListEnd" multiple οndblclick="txTimeValue(this.value,2);">
      <script>writeList(1,false);</script></select></span>
     </div>
     </td>
    </tr>
    <tr>
      <td align="left" nowrap colspan="3">
      <div id="page"></div> 
      </td>
      </tr>
     </table>   
    </div>
    </td>
    <td colspan="2" valign="top">
    <div>
     <table>
    <tr>
     <td> <div>
      <OBJECT classid="CLSID:e62d1a95-8299-4b94-85d0-731dc125a60d" 
       CODEBASE = "/ocx/IMMP4.cab#Version=1,0,0,0" width=352 height=288 align="middle" BORDER="0" id="Player2" >
        <PARAM NAME="AutoPlay" VALUE="0">
        <PARAM NAME="DisplayRate" VALUE="0">
        <PARAM NAME="Source" VALUE="">
        <FONT COLOR=red SIZE=5> Can't find object</FONT>
      </OBJECT>
       </div>
      </td>
     <td></td>
    </tr>
   </table>
      <div>
              <table>
                <tr>
                  <td width="352">  
         <p>
       <h3>Select a interval time that you want to download these videos recorded between it.</h3></p>
                        <input type="text" name="time_start" size="15">
                      &nbsp;Double click the start time listed.<br/>
                      <br/>
                     <!-- <input name="time_end" type="text" size="15">
                      &nbsp;Double click the end time listed..
       <br/>
       <br/>    -->     </td>
                </tr>
                <tr>
                  <td><input name="record_button" type="button" width="100" onClick='JavaScript:jsCtrlDevice(7,"")' value="Get record clip"></td>
                </tr>
     <tr>
                  <td height="20"></td>
                </tr>
    <td align="left" nowrap colspan="3">
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
     <!--<td class="button"><input name="button2" type="button"  class="btnNormal" onClick='JavaScript:jsCtrlDevice(4,"")' value="record_schedule" width="75"></td>-->   
     <td class="button"><input type="button" name="tmlst" value="Get time list" width="100" class="btnNormal" onClick='jsCtrlDevice(5,"")'><br/></td>
     <td></td>
     <td></td>           
     </tr>
     <tr>
      <td colspan="3">
       <div id="record_type_hid" style="display:none">
        <table>
         <tr>
          <td colspan="3" height="10"></td>
         </tr>
         <tr>
          <td colspan="3"><h3>Set the record type.</h3></td>
         </tr>
         <tr>   
          <td class="oddItem" height="10" colspan="3">   
          off_all<input type="radio" name="record_type" value="1" checked="checked">
          on_all<input type="radio" name="record_type" value="2"  >
          on_schedule<input type="radio" name="record_type" value="3" >
          <input type="button" value="record type" width="75" class="btnNormal" onClick='JavaScript:jsCtrlDevice(1,"")'>          </td>
         </tr>
        </table>
       </div>      </td>
     </tr>   
    </table>    </td>
              </table>
       </div>
    </div>    
  </td>
     </tr>
 </table>
 </form>
 </div>
 <div>
 <input type="button" value="Add" onClick="addTabRow();"><input type="button" value="Del all" onClick="delAllTabRow();">   
        <table border="1">   
            <thead>   
                <tr>   
                    <td align="center" width="25"> Hour</td>   
                    <td align="center" width="25">Time</td>   
                    <td align="center" width="100">Record Type</td>
     <td align="center" width="25"> Hour</td>   
                    <td align="center" width="25">Time</td>   
                    <td align="center" width="100">Record Type</td>
                </tr>   
            </thead>   
            <tbody id="mybody"> 
            </tbody>
   <tr>   
                   <td align="center" width="25" colspan="6"><input type="button" name="schedule" value="schedule"/></td>
   </tr>   
        </table> 
 </div>
  </div>
  <div id="div_table" class="class_title" style="display:none" ondbClick='hiddenDiv("div_table")'>  
  </div>
</div> 
<OBJECT id="Player" width="0" height="0" BORDER=0 classid="CLSID:e62d1a95-8299-4b94-85d0-731dc125a60d">
</OBJECT>  
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值