增加的新列为什么里面的表格颜色不能和第一行一样?
1.增加的新列为什么里面的表格颜色不能和第一行一样目的是让增加的第二列也把第一列的背景色带过来,增加和第一行完全一样
2.搞了好长时间都弄不好,关键是对代码不熟悉,只靠自己猜,请高手指点
<form action=" " name="form1 ">
<input onclick= "deleteRow() " name="Submit " value="删除 " type="text" /> <input maxlength="4" size="4" name="num " value="1 " type="text" /> <input onclick= "insertRow() " name="Submit2 " value="增加 " type="text" /> <br />
<table id="table1 " border="0" cellspacing="1" cellpadding="2" width="900" bgcolor="#000000">
<tbody>
<tr>
<td width="87"><select name="select "></select></td>
<td bgcolor="#ffffff" bordercolor="#ffffff" width="277"> <input id="$label-1$" class="Label" name="label-1" value="标题" type="text" /></td>
<td bgcolor="#ffffff" bordercolor="#ffffff" width="277"> <input id="$label-2$" class="Label" name="label-2" value="紧急程度" type="text" /></td>
<td bgcolor="#ffffff" bordercolor="#ffffff" width="277"> </td>
<td bgcolor="#ffffff" bordercolor="#ffffff" width="277"> </td>
<td bgcolor="#ffffff" bordercolor="#ffffff" width="277"> </td>
<td><input name="0 " value="0 " type="text" /></td>
</tr>
</tbody>
</table>
</form>
<script language=javascript>
function deleteRow()
{
var obj=document.getElementById( "table1 ")
var rowIndex=obj.childNodes[0].childNodes.length;
if(rowIndex> 7)
{
document.getElementById( "num ").value=document.getElementById( "num ").value-parseInt(1)
obj.deleteRow(rowIndex-parseInt(1));
}
}
function insertRow()
{
var obj=document.getElementById( "table1 ")
var rowIndex=obj.childNodes[0].childNodes.length;
var objTR=obj.insertRow(rowIndex);
var objTD1=objTR.insertCell();
var objTD2=objTR.insertCell();
var objTD3=objTR.insertCell();
var objTD4=objTR.insertCell();
var objTD5=objTR.insertCell();
var objTD6=objTR.insertCell();
var objTD7=objTR.insertCell();
rowIndex2=parseInt(rowIndex)+parseInt(1)
objTD1.innerHTML=obj.childNodes[0].childNodes[rowIndex-1].childNodes[0].innerHTML.replace(/(name=)(\ ")*(select)(\d)(\2)/gi, "$1$2$3 "+rowIndex2+ "$5 ")
objTD2.innerHTML=obj.childNodes[0].childNodes[rowIndex-1].childNodes[1].innerHTML.replace(/(name=)(\ ")*(textfield)(\d)(\2)/gi, "$1$2$3 "+rowIndex2+ "$5 ")
objTD3.innerHTML=obj.childNodes[0].childNodes[rowIndex-1].childNodes[2].innerHTML.replace(/(=)(\ ")*(\d)(\2)/gi, "$1$2 "+rowIndex2+ "$4 ")
objTD4.innerHTML=obj.childNodes[0].childNodes[rowIndex-1].childNodes[2].innerHTML.replace(/(=)(\ ")*(\d)(\2)/gi, "$1$2 "+rowIndex2+ "$4 ")
objTD5.innerHTML=obj.childNodes[0].childNodes[rowIndex-1].childNodes[2].innerHTML.replace(/(=)(\ ")*(\d)(\2)/gi, "$1$2 "+rowIndex2+ "$4 ")
objTD6.innerHTML=obj.childNodes[0].childNodes[rowIndex-1].childNodes[2].innerHTML.replace(/(=)(\ ")*(\d)(\2)/gi, "$1$2 "+rowIndex2+ "$4 ")
objTD7.innerHTML=obj.childNodes[0].childNodes[rowIndex-1].childNodes[2].innerHTML.replace(/(=)(\ ")*(\d)(\2)/gi, "$1$2 "+rowIndex2+ "$4 ")
document.getElementById( "num ").value=parseInt(document.getElementById( "num ").value)+parseInt(1)
}
</script>