<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Nothing is impossible for a willing heart

    I belive I can

     

    javascript動態增加一行,刪除一行[轉載]

    <HTML>
    <HEAD>
    <META content="text/html; charset=gb2312" http-equiv=Content-Type>

    <SCRIPT language=javascript>
    var modified=0
    var currentLine=-1//該變量似乎保存"ln"屬性;lightOn函數中line記錄實際行數
    var line=-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>del";
    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  id=tdt>
    <TH width="10%"><INPUT name=date type=hidden> Date
    <TH width="30%"><INPUT name=diagnosis type=hidden>
    color=white>Diagnosis
    <TH width="60%"><INPUT name=medication type=hidden>
    color=white>Medication
    <TH width=10>X <INPUT name=PLID type=hidden> <INPUT name=edit
    type=hidden></TH>
    </TR>
    <TR bgColor=#e0e0e0 class=tableData id=tdt onclick=lightOn() ln="1">
    <TD class=scheduleButtonVisible onclick=delIt() onmouseout=mouseOut()
    onmouseover=mouseOver() ln="1"><INPUT name=PLID type=hidden value=54
    ln="1"> <INPUT name=edit type=hidden value=0>del</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>

    </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=center class=controlPanel onclick=newHospitalVisit()
    onmouseout="this.className='controlPanel'"
    onmouseover="this.className='controlPanelMouseOver'">Add a New
    Record, click here</TD>
    </TR>
    </TBODY>
    </TABLE>
    </DIV>
    </FORM>
    </BODY>
    </HTML>


    我覺得這種寫法不怎么好.重用性差.現在一般都比較流行dhtml來做表格的增添刪.其實dhtml的免費版本已經可以滿足我們的一般要求了.當然,如果要
    新增一些功能的話,可以直接改它的源代碼.我們現在的做法就是自己改它的代碼,增加自己想要的功能.dhtml我覺得唯一不好的就是,如果xml文件包含有&,/n,/t等字符的時候,dhtml加載xml時候,就出錯了.

    posted on 2006-09-29 21:47 JAVA_UFO 閱讀(1747) 評論(2)  編輯  收藏 所屬分類: javascript

    評論

    # re: javascript動態增加一行,刪除一行[轉載] 2012-10-12 17:19 zhangsan

    呵呵呵
      回復  更多評論   

    # re: javascript動態增加一行,刪除一行[轉載] 2012-10-12 19:57 張三他妹

    @zhangsan
    你是我的blog這么多年第一個雁過留毛的人,謝謝你的光臨。  回復  更多評論   


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


    網站導航:
     

    導航

    統計

    常用鏈接

    留言簿(1)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 国内一级一级毛片a免费| 2019亚洲午夜无码天堂| 最近中文字幕免费mv视频7| 国产一级一毛免费黄片| 亚洲欧美中文日韩视频| 亚洲精品午夜无码专区| 日本人的色道www免费一区| 最近中文字幕完整免费视频ww| 一级做a爱过程免费视| 亚洲久热无码av中文字幕 | 亚洲欧美自偷自拍另类视| 久久久久亚洲AV无码专区体验| 亚洲精品天堂成人片?V在线播放| 最近最新的免费中文字幕| 222www免费视频| 日本卡1卡2卡三卡免费| 高清永久免费观看| 又硬又粗又长又爽免费看 | 人妻免费久久久久久久了| 亚洲国产午夜精品理论片在线播放 | 久久精品国产亚洲AV电影| 亚洲乱码一区二区三区在线观看| 亚洲成A人片在线观看无码3D| 日韩a级毛片免费视频| 无码av免费毛片一区二区| 99久久免费精品高清特色大片| 成全动漫视频在线观看免费高清版下载| 无码色偷偷亚洲国内自拍| 亚洲a∨无码一区二区| 亚洲youwu永久无码精品| 亚洲人成自拍网站在线观看| 久久久久亚洲国产| 亚洲男人天堂2018av| 亚洲kkk4444在线观看| 亚洲一区AV无码少妇电影| 99亚偷拍自图区亚洲| 亚洲人成网亚洲欧洲无码| 亚洲国产精品无码久久九九大片| 亚洲熟妇无码av另类vr影视| 亚洲欧美一区二区三区日产| 亚洲avav天堂av在线网毛片|