我想要以動態生成輸入文本的形式獲取客戶的電話號碼。我做了這個處理在JavaScript中動態生成的輸入文本陣列
<HTML>
<HEAD>
<TITLE> get telephones </TITLE>
<SCRIPT language="javascript">
function add(type) {
//Create an input text dynamically.
if(typeof add.counter=='undefined')
{
add.counter=0;
}
add.counter++;
var element = document.createElement("input");
//Assign different attributes to the element.
element.setAttribute("type", type);
element.setAttribute("value", "");
element.setAttribute("name", type.concat(add.counter));
var foo = document.getElementById("fooBar");
//Append the element in page (in span).
foo.appendChild(element);
return add.counter;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM action="test1.php" method="post">
//here I think there is a problem
<INPUT type="button" value="Add" onclick="<?php echo "add('text')";?>"/>
<INPUT type="submit" value="Add" />
<span id="fooBar"> </span>
</FORM>
</BODY>
</HTML>
我想,如果你設置輸入名稱「無論[]」,那麼PHP將得到輸入文本,或計數器
你能給提前 –
詳情please.thanks我給你足夠多的細節** **更多。沒有詳細信息,我的答案看起來像「append []到您的輸入名稱,你會得到一個數組,當你張貼表單數據」 – keymone