欢迎光临
我们一直在努力

例子源码:纯DHTML编写的可编辑增删的表格

建站超值云服务器,限时71元/月

<html>
<head>
<meta content="text/html; charset=gb2312" http-equiv=content-type>
<style type=text/css>body {
background: white; color: black; font-family: verdana,arial,helvetica; font-size: 12px
}
.tabledata {
background: white; border-bottom: white 1px dashed; border-left: white 1px dashed; border-right: white 1px dashed; border-top: white 1px dashed; color: black; cursor: hand; font-family: verdana,arial,helvetica; font-size: 12px
}
.tabledatasel {
background: #6090d0; border-bottom: #6090d0 1px dashed; border-left: #6090d0 1px dashed; border-right: #6090d0 1px dashed; border-top: #6090d0 1px dashed; color: white; cursor: hand; font-family: verdana,arial,helvetica; font-size: 12px
}
.tabledatahit {
background: #d0e0ff; border-bottom: #d0e0ff 1px dashed; border-left: #d0e0ff 1px dashed; border-right: #d0e0ff 1px dashed; border-top: #d0e0ff 1px dashed; color: black; cursor: hand; font-family: verdana,arial,helvetica; font-size: 12px
}
.tabledataover {
background: #d0e0ff; border-bottom: #d0e0ff 1px dashed; border-left: #d0e0ff 1px dashed; border-right: #d0e0ff 1px dashed; border-top: #d0e0ff 1px dashed; color: black; cursor: hand; font-family: verdana,arial,helvetica; font-size: 12px
}
.controlpanel {
background: silver; color: black; cursor: hand; font-family: verdana,arial,helvetica; font-size: 14px
}
.controlpanelmouseover {
background: #d0e0ff; color: black; cursor: hand; font-family: verdana,arial,helvetica; font-size: 14px
}
.delmouseover {
background: #d0e0ff; color: black; cursor: hand; font-family: verdana,arial,helvetica; font-size: 14px
}
.schedulebuttonvisible {
background: silver; border-bottom: gray 1px dashed; border-left: white 1px dashed; border-right: gray 1px dashed; border-top: white 1px dashed; color: black; cursor: hand; font-family: webdings; font-size: 12px
}
</style>
<script language=javascript>
var modified=0
var currentline=-1
function lighton(ln)
{
if (ln==null)
  ln=parseint(event.srcelement.ln,10)
for (i=1;i<pllist.rows.length;i++)
  if (tdt[i].ln==ln)
   line=i
cln=currentline
oldline=-1
for (i=1;i<pllist.rows.length;i++)
  if (tdt[i].ln==cln)
   oldline=i
if (line==oldline)
  return
//if td <0 then only clear all title
if (line>0)
{
  document.all.tdt[line].classname="tabledatahit";
  document.ecform("date")[line].classname="tabledatahit";
  document.ecform("diagnosis")[line].classname="tabledatahit";
  document.ecform("medication")[line].classname="tabledatahit";
  if (oldline>0)
  {
   document.all.tdt[oldline].classname="tabledata";
   document.ecform("date")[oldline].classname="tabledata";
   document.ecform("diagnosis")[oldline].classname="tabledata";
   document.ecform("medication")[oldline].classname="tabledata";
  }
  currentline=ln
}
}
function delit()
{
line=parseint(event.srcelement.ln,10)
  
if (line>0)
  for (i=1;i<pllist.rows.length;i++)
   if (tdt[i].ln==line)
   {
    if (document.ecform.diagnosis[i].value.length>0 || document.ecform.medication[i].value.length>0 || document.ecform.date[i].value.length>0)
     if (!confirm("are you sure you want to delete this record?"))
      return
    pllist.deleterow(i)
   }
}
function modifiedit(field)
{
// field.value=checktext(field.value);
modified=1
line=parseint(event.srcelement.ln,10)
  
if (line>0)
   for (i=1;i<pllist.rows.length;i++)
    if (tdt[i].ln==line)
     document.ecform.edit[i].value=1
}
function newhospitalvisit()
{
newrow=pllist.insertrow(pllist.rows.length);
newrow.id="tdt";
newrow.ln=allcount;
newrow.bgcolor="#e0e0e0";
newrow.classname="tabledata";
newrow.onclick=lighton;

c1=newrow.insertcell(0);
c1.id="delitem";
c1.ln=allcount;
c1.classname="schedulebuttonvisible";
c1.onclick=delit;
c1.onmouseover=mouseover;
  c1.onmouseout=mouseout;
c1.innerhtml="<input type=hidden name=plid value=0><input type=hidden name=edit value=0>";
c2=newrow.insertcell(1);
c2.ln=allcount;
c2.innerhtml="<input type=text size=10 maxlength=10 name=date ln="+allcount+" class=tabledata onkeyup=modifiedit()>"
c3=newrow.insertcell(2);
c3.ln=allcount;
c3.innerhtml="<input type=text size=25 maxlength=50 name=diagnosis ln="+allcount+" class=tabledata onkeyup=modifiedit()>"
c4=newrow.insertcell(3);
c4.ln=allcount;
c4.innerhtml="<input type=text size=58 maxlength=100 name=medication ln="+allcount+" class=tabledata onkeyup=modifiedit()>"
allcount++
}
function mouseover()
{
event.srcelement.classname="delmouseover"
}
function mouseout()
{
event.srcelement.classname="schedulebuttonvisible"
}
</script>
</head>
<body bgcolor=white>
<form method=post name=ecform>
  <meta content="mshtml 5.00.2920.0" name=generator>
  <div id=div1
style="left: 0px; position: absolute; top: 0px; visibility: visible; width: 658px">
    <table bgcolor=silver border=2 bordercolordark=gray bordercolorlight=silver
cellpadding=2 cellspacing=1 cols=1 id=pllist rules=rows width="100%">
      <tbody>
      <tr bgcolor=#0a6846 id=tdt>
        <th width=10><font color=white>x
          <input name=plid type=hidden>
          <input
      name=edit type=hidden>
          </font></th>
        <th width="10%">
          <input name=date type=hidden>
          <font color=white>date </font>
        <th width="30%">
          <input name=diagnosis type=hidden>
          <font
      color=white>diagnosis </font>
        <th width="60%">
          <input name=medication type=hidden>
          <font
      color=white>medication </font>
      </tr>
      <tr bgcolor=#e0e0e0 class=tabledata id=tdt onclick=lighton() ln="1">
        <td class=schedulebuttonvisible onclick=delit() onmouseout=mouseout()
    onmouseover=mouseover() ln="1"><font size=2>
          <input name=plid type=hidden
      value=54 ln="1">
          <input name=edit type=hidden value=0>
          </font></td>
        <td ln="1">
          <input class=tabledata maxlength=10 name=date
      onkeyup=modifiedit(this) size=10 ln="1">
        </td>
        <td ln="1">
          <input class=tabledata maxlength=50 name=diagnosis
      onkeyup=modifiedit(this) size=25 value="what do you think of it?"
    ln="1">
        </td>
        <td ln="1">
          <input class=tabledata maxlength=100 name=medication
      onkeyup=modifiedit(this) size=58 value="like it?" ln="1">
        </td>
      </tr>
      <tr bgcolor=#e0e0e0 class=tabledata id=tdt onclick=lighton() ln="2">
        <td class=schedulebuttonvisible onclick=delit() onmouseout=mouseout()
    onmouseover=mouseover() ln="2"><font size=2>
          <input name=plid type=hidden
      value=55 ln="2">
          <input name=edit type=hidden value=0>
          </font></td>
        <td ln="2">
          <input class=tabledata maxlength=10 name=date
      onkeyup=modifiedit(this) size=10 value=01/01/1999 ln="2">
        </td>
        <td ln="2">
          <input class=tabledata maxlength=50 name=diagnosis
      onkeyup=modifiedit(this) size=25 value="it`s a test" ln="2">
        </td>
        <td ln="2">
          <input class=tabledata maxlength=100 name=medication
      onkeyup=modifiedit(this) size=58 value="how about it?" ln="2">
        </td>
      </tr>
      <tr bgcolor=#e0e0e0 class=tabledata id=tdt onclick=lighton() ln="3">
        <td class=schedulebuttonvisible onclick=delit() onmouseout=mouseout()
    onmouseover=mouseover() ln="3"><font size=2>
          <input name=plid type=hidden
      value=56 ln="3">
          <input name=edit type=hidden value=0>
          </font></td>
        <td ln="3">
          <input class=tabledata maxlength=10 name=date
      onkeyup=modifiedit(this) size=10 value=02/01/2000 ln="3">
        </td>
        <td ln="3">
          <input class=tabledata maxlength=50 name=diagnosis
      onkeyup=modifiedit(this) size=25 value="another test" ln="3">
        </td>
        <td ln="3">
          <input class=tabledata maxlength=100 name=medication
      onkeyup=modifiedit(this) size=58 ln="3">
        </td>
      </tr>
      </tbody>
    </table>
    <script>
allcount=4
</script>
    <table align=center border=1 bordercolordark=white bordercolorlight=gray
cellpadding=1 cellspacing=1 class=controlpanel cols=4 rules=all width="100%"
nowrap>
      <tbody>
      <tr>
        <td align=middle class=controlpanel onclick=newhospitalvisit()
    onmouseout="this.classname=controlpanel"
    onmouseover="this.classname=controlpanelmouseover"><font size=2>add a new
          record, click here</font></td>
      </tr>
      </tbody>
    </table>
  </div>
</form>
</body>
</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 例子源码:纯DHTML编写的可编辑增删的表格
分享到: 更多 (0)

相关推荐

  • 暂无文章