0
這裏是我的代碼如何用另一個文本框中的文本使用jQuery來填充動態文本框?
var rowCount = $('#tblApplIdn tr').length;
var index = rowCount + 1;
$('#tblApplIdn').append("<tr><td><input type='hidden' name='identitity.Index' value='" + index + "' /><input type='text' name='identitity[" + index + "].TypeOfIdentification' value=" + $('#TypeOfIdentification').val() + "></td><td><input type='text' class='textreq' name='identitity[" + index + "].IdentityNumber' value=" + value + "></td><td><input type='text' class='textreq' name='identitity[" + index + "].IssueDate' value=" + $('#IssueDate').val() + "></td><td><input type='text' class='textreq' name='identitity[" + index + "].ExpiryDate' value=" + $('#ExpiryDate').val() + "></td><td><input type='text' class='textreq' name='identitity[" + index + "].DateReceived' value=" + $('.receivedDte').val() + "></td><td><input type='text' class='textreq' name='identitity[" + index + "].IssuingAuthority' value=" + $('.issAuthority').val() + "></td><td><input type='text' name='identitity[" + index + "].PlaceofIssue' value=" + $('#PlaceofIssue').val() + "></td><td><input type='text' class='textreq' value=" + $('#Countryofissue option:selected').text() + "><input type='hidden' class='textreq' name='identitity[" + index + "].Countryofissue' value=" + $('#Countryofissue').val() + "></td><td><input type='button' name='remove' class='remove' value='Remove' id='" + index + "'/></tr>");
上面的代碼不正確填寫動態文本框。假設我說IdentityNumber = AA 1234,那麼動態文本框只需要AA,並且不會在空格之後填充任何內容。我嘗試了一個變量,然後將該值賦值給該變量,然後將該變量作爲值傳遞,但它的行爲方式相同。我有12左右的選項卡,幾乎所有的選項卡需要添加動態文本框,單擊添加按鈕後,用戶可以選擇添加多個記錄。在檢查元素內,我可以找到
<input type="text" class="textreq valid" name="identitity[2].IdentityNumber" value="AA" 1234 aria-invalid="false">
如何在動態文本框中包含整個值。我瀏覽並嘗試了所有我能找到的東西,但它不起作用。任何評論和答案真的很感激。
您沒有正確引用代碼。 –
@BhojendraNepal可以ü發表引用代碼,如你在答案部分說的例子,如果這符合我的要求,我會將其標記爲已接受。謝謝 – User
應該是這樣的:) name =「identitity ['」+ index +「'] .TypeOfIdentification」 –