我已经有添加多个文本字段的javascript代码:我想知道添加了多少字段并将它们存储在mysql db中
EX:添加了 10 个字段 $_GET['1'], $_GET['2'] ...... $_GET['10'] 我怎么知道具体的字段数在php中提交到下一页?
<html>
<head>
<script type="text/javascript">
var intTextBox=0;
//FUNCTION TO ADD TEXT BOX ELEMENT
function addElement()
{
intTextBox = intTextBox + 1;
var contentID = document.getElementById('content');
var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strText'+intTextBox);
newTBDiv.innerHTML = "Text "+intTextBox+": <input type='text' id='" + intTextBox + "' name='" + intTextBox + "'/>";
contentID.appendChild(newTBDiv);
}
//FUNCTION TO REMOVE TEXT BOX ELEMENT
function removeElement()
{
if(intTextBox != 0)
{
var contentID = document.getElementById('content');
contentID.removeChild(document.getElementById('strText'+intTextBox));
intTextBox = intTextBox-1;
}
}
</script>
</head>
<body>
<form action="testjs.php">
<div id="content"></div>
<p><input type="button" onclick="addElement()" value="ADD" > <input type="button" onclick="removeElement()" value="REMOVE" ></p>
<input type="submit" value="SUBMIT">
</form>
</body>
</html>