每次单击添加行时,我都有一个脚本将行添加到带有文本字段的表中:
<script language = "javascript">
var x = 0;
function addRow(){
var tbody = document.getElementById(tabID).getElementsByTagName("tbody")[0];
var row = document.createElement("tr")
var data1 = document.createElement("td")
var data2 = document.createElement("td")
var element = document.createElement("input");
element.setAttribute("type", type);
element.setAttribute("name", type);
element.setAttribute("id", "Name"+x);
element.setAttribute("style","width:95px");
var element1 = document.createElement("input");
element1.setAttribute("type", type);
element1.setAttribute("name", type);
element1.setAttribute("id", "Address"+x);
element1.setAttribute("style","width:95px");
var foo = document.tbody;
data1.appendChild(element)
data2.appendChild(element1)
row.appendChild(data1)
row.appendChild(data2)
tbody.appendChild(row)
x++;
}
</script>
提交后如何将变量 x 的值传递给 php,以便我可以计算我应该执行多少循环?