javascript 动态添加删除控件怎么取值啊

<script language="javascript">

var i = 0,j = 0;     //行号与列号
var oNewRow,oNewRow2,oNewRow3;    //定义插入行对象
var oNewCell1,oNewCell2,oNewCell3;     //定义插入列对象
//添加条件行
function AddRow()
{
i = document.all.MyTable.rows.length;

oNewRow = document.all.MyTable.insertRow(i);
oNewRow.id = j;
oNewRow2 = document.all.MyTable.insertRow(i+1);
oNewRow2.id = j+1;
oNewRow3 = document.all.MyTable.insertRow(i+2);
oNewRow3.id = j+2;
var cont=j+1;
//添加第一行
oNewCell1 = document.all.MyTable.rows[i].insertCell(0)
//oNewCell1.innerHTML = "新描述"+ j +"<input type='text' id='Value" + j + "'"+" size='14' value=\"\">";
oNewCell1.innerHTML ="新描述:"+cont+"<a name=Del" + j + " onClick='DelCurrentRow(" + j + ");' href=';' >删除当前行</a>";
//添加第二行>
oNewCell2 = document.all.MyTable.rows[i+1].insertCell(0)
oNewCell2.innerHTML = "<textarea id='Value" + j + "'"+"  style='width: 728px; height: 75px;' MaxLength='700' value=\"\">";
//添加第三行 >
oNewCell3 = document.all.MyTable.rows[i+2].insertCell(0)
oNewCell3.innerHTML = "<hr width='700px'>"
j++;
}

//删除行
function DelCurrentRow(j)
{
with(document.all.MyTable)
{
for (var i=0;i<rows.length;i++)
{
if (rows[i].id == j)
{
deleteRow(i);
deleteRow(i);
deleteRow(i);
}

}
}
}
</script>

<hr width="700px">
<table>
    <tr>
        <td>
            <table cellpadding="0" cellspacing="0" align="left" width="100%" style="font-family: 宋体;
                font-size: 12px; border: 0px;">
                <tr>
                    <td style="border: 0px;">
                    </td>
                </tr>
                <tr>
               
                    <td style="border: 0px; height: 14px;">
                        <a id="attach" style="font-family: 宋体; font-size: 12px;" title="如果您要发送多个,您只需多次点击“添加”即可."
                            onclick="AddRow();" href=";" name="attach">添加新描述</a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table cellpadding="0" cellspacing="0" align="left" width="100%" style="font-family: 宋体;
                font-size: 12px; border: 0px;" id="MyTable" border="0">
            </table>
        </td>
    </tr>
</table>

你可能感兴趣的:(JavaScript)