我有一個腳本行添加到與文本框的表 每次我點擊添加一行:如何從javascript傳送給PHP傳遞變量提交後
<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>
如何傳遞到PHP我的變量的值x提交後,所以我可以計算我應該做多少循環?
TRY'的document.getElementById(「DIVID」)。innerHTML的= x' – diEcho
其添加爲上一個隱藏的表單元素提交 – mmertel