最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Js實(shí)現(xiàn)動態(tài)添加刪除Table行示例

 更新時(shí)間:2014年04月14日 15:07:04   作者:  
這篇文章主要介紹了Js動態(tài)添加刪除Table行的具體實(shí)現(xiàn),需要的朋友可以參考下
最近做項(xiàng)目遇到要?jiǎng)討B(tài)添加、刪除表格行的操作,實(shí)現(xiàn)如下

html代碼
復(fù)制代碼 代碼如下:

<table cellpadding="0" cellspacing="0" border="1" style="margin:auto; width:96%;" id="LearnInfoItem">
<tr >
<td colspan="8" bgcolor="#96E0E2" style="height:30px;" ><h3 style="text-align:center; margin:0;">主要學(xué)習(xí)簡歷</h3></td>
</tr>
<tr id="tr1">
<td class="tdStyle2">起訖時(shí)間 </td>

<td class="tdStyle2">畢業(yè)院校</td>

<td class="tdStyle2">所學(xué)專業(yè)</td>

<td class="tdStyle2">學(xué)制</td>

<td class="tdStyle2">學(xué)位</td>

<td class="tdStyle2">學(xué)習(xí)方式</td>

<td class="tdStyle2">文化程度</td>

<td class="tdStyle2">
<input type="button" name="LearnAdd" value="添加" onclick="LearnAddSignRow()" />
<input name='LearnTRLastIndex' type='hidden' id='LearnTRLastIndex' value="1" />
</td>

</tr>
</table>

javascript代碼:
復(fù)制代碼 代碼如下:

<script language="javascript" type="text/javascript">// Example: obj = findObj("image1");

function findObj(theObj, theDoc)
{
var p, i, foundObj;
if(!theDoc) theDoc = document;
if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
{
theDoc = parent.frames[theObj.substring(p+1)].document;
theObj = theObj.substring(0,p);
}
if(!(foundObj = theDoc[theObj]) && theDoc.all)
foundObj = theDoc.all[theObj];
for (i=0; !foundObj && i < theDoc.forms.length; i++)
foundObj = theDoc.forms[i][theObj];
for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
foundObj = findObj(theObj,theDoc.layers[i].document);
if(!foundObj && document.getElementById)
foundObj = document.getElementById(theObj);
return foundObj;
}


//添加一行學(xué)習(xí)簡歷
function LearnAddSignRow(){ //讀取最后一行的行號,存放在LearnTRLastIndex文本框中
var LearnTRLastIndex = findObj("LearnTRLastIndex",document);
var rowID = parseInt(LearnTRLastIndex.value);

var signFrame = findObj("LearnInfoItem",document);
//添加行
var newTR = signFrame.insertRow(signFrame.rows.length);
newTR.id = "LearnItem" + rowID;

//添加列:起訖時(shí)間
var newNameTD=newTR.insertCell(0);
//添加列內(nèi)容
newNameTD.innerHTML = "<input name='txtLearnStartDate" + rowID + "' id='txtLearnStartDate" + rowID + "' type='text' class='inputStyle' />";

//添加列:畢業(yè)院校
var newNameTD=newTR.insertCell(1);
//添加列內(nèi)容
newNameTD.innerHTML = "<input name='txtName" + rowID + "' id='txtName" + rowID + "' type='text' class='inputStyle' />";

//添加列:所學(xué)專業(yè)
var newEmailTD=newTR.insertCell(2);
//添加列內(nèi)容
newEmailTD.innerHTML = "<input name='txtEMail" + rowID + "' id='txtEmail" + rowID + "' type='text' class='inputStyle' />";

//添加列:學(xué)制
var newTelTD=newTR.insertCell(3);
//添加列內(nèi)容
newTelTD.innerHTML = "<input name='txtTel" + rowID + "' id='txtTel" + rowID + "' type='text' class='inputStyle' />";

//添加列:學(xué)位
var newMobileTD=newTR.insertCell(4);
//添加列內(nèi)容
newMobileTD.innerHTML = "<input name='txtMobile" + rowID + "' id='txtMobile" + rowID + "' type='text' class='inputStyle' />";

//添加列:學(xué)習(xí)方式
var newMobileTD=newTR.insertCell(5);
//添加列內(nèi)容
newMobileTD.innerHTML = "<input name='txtMobile" + rowID + "' id='txtMobile" + rowID + "' type='text' class='inputStyle' />";

//添加列:文化程度
var newCompanyTD=newTR.insertCell(6);
//添加列內(nèi)容
newCompanyTD.innerHTML = "<input name='txtCompany" + rowID + "' id='txtCompany" + rowID + "' type='text' class='inputStyle' />";


//添加列:刪除按鈕
var newDeleteTD=newTR.insertCell(7);
//添加列內(nèi)容
newDeleteTD.innerHTML = "<div align='center'><input id='txtDel" + rowID + "' type='button' value='刪除' onclick=\"LearnDeleteRow('LearnItem" + rowID + "')\" class='inputStyle' /></div>";

//將行號推進(jìn)下一行
LearnTRLastIndex.value = (rowID + 1).toString() ;
}
//刪除指定行
function LearnDeleteRow(rowid){
var signFrame = findObj("LearnInfoItem",document);
var signItem = findObj(rowid,document);

//獲取將要?jiǎng)h除的行的Index
var rowIndex = signItem.rowIndex;

//刪除指定Index的行
signFrame.deleteRow(rowIndex);

}

}
</script>

實(shí)現(xiàn)效果:

相關(guān)文章

最新評論

调兵山市| 大名县| 绥阳县| 麻江县| 溧阳市| 沐川县| 涿鹿县| 松原市| 芦溪县| 资中县| 西乌| 洪泽县| 汝南县| 申扎县| 共和县| 伊吾县| 沙雅县| 九龙坡区| 甘泉县| 昂仁县| 蓝田县| 通海县| 惠东县| 青岛市| 桐庐县| 抚顺市| 岫岩| 娄底市| 安远县| 沙河市| 北碚区| 鹿泉市| 建水县| 分宜县| 奉节县| 吴桥县| 三亚市| 洮南市| 新安县| 镇沅| 伊川县|