這個問題出現在solving my last question之後,我想從隱藏窗體中獲取一些值,但是當我嘗試僅檢索到空字符串時,我只考慮使用數組來存儲引入的信息,但是我想知道是否有可能僅僅在之後檢索它,以及如何檢索它。如何獲取隱藏或自動生成的內容的值?
此外,還有是與一些JavaScript動態生成的表:
function createTable(){
if (document.getElementById("invoiceFormat").rowNumber.value != ""){
rows = document.getElementById("invoiceFormat").rowNumber.value;
}
var contents = "<table id='mt'><tr>";
if (document.getElementById("invoiceFormat").cb1[0].checked){
contents = contents + "<td class='htd'>Quantity</td>";
}if (document.getElementById("invoiceFormat").cb1[1].checked){
contents = contents + "<td class='htd'>Description</td>";
}if (document.getElementById("invoiceFormat").cb1[2].checked){
contents = contents + "<td class='htd'>Unitary Price</td>";
}if (document.getElementById("invoiceFormat").cb1[3].checked){
contents = contents + "<td class='htd'>Subtotal</td>";
}
for (i=4; i<=k; i++){
if (document.getElementById("invoiceFormat").cb1[i].checked){
contents = contents + "<td>" + document.getElementById("invoiceFormat").cb1[i].value + "</td>";
}
}
contents = contents + "</tr>";
for (j=1; j<=rows; j++){
contents = contents + "<tr>";
for (l=0; l<=k; l++){
if (document.getElementById("invoiceFormat").cb1[l].checked){
hotfix = l +1;
contents = contents + "<td> <input id='cell" + j + "_" + hotfix + "' name='cell' type='text' size='15' /> </td>";
}
}
contents = contents + "</tr>";
}
contents = contents + "</table>";
var createdTable = document.getElementById("mainTable");
createdTable.innerHTML = contents;
}
它的創建後,我試圖訪問它,但沒有運氣到目前爲止,我不能得到什麼用戶在創建的輸入字段中輸入。我怎樣才能做到這一點?
我使用的是JavaScript的原料使用jQuery所以帶或不帶庫的答案,歡迎:)