Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用jquery用另一个文本框中的文本填充动态文本框?_Jquery_Jquery Ui - Fatal编程技术网

如何使用jquery用另一个文本框中的文本填充动态文本框?

如何使用jquery用另一个文本框中的文本填充动态文本框?,jquery,jquery-ui,Jquery,Jquery Ui,这是我的密码 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 + "]

这是我的密码

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>");
var rowCount=$('tblApplIdn tr')。长度;
var指数=行数+1;
$('#tblApplIdn')。追加(“”);
上述代码无法正确填充动态文本框。假设我说IdentityNumber=aa1234,那么动态文本框只接受AA,不填充空格后面的任何内容。我尝试获取一个变量,然后将值赋给该变量,然后这个变量作为值传递时,其行为仍然相同。我有大约12个标签,几乎所有的标签都需要在点击添加按钮时添加动态文本框,用户可以选择添加多个记录。在inspect元素中我可以找到

<input type="text" class="textreq valid" name="identitity[2].IdentityNumber" value="AA" 1234 aria-invalid="false">


如何在动态文本框中包含整个值。我浏览并尝试了所有我能找到的,但它不起作用。非常感谢您的评论和回答。

好的。这可能不是一个最佳的解决方案,但只是为了达到您可以使用它的要求!!甚至我也不知道为什么不能用空格附加值,所以我要做的是将值存储在每个变量中,然后将其分配给最后一个
tr
s
td
的每个
input
,如下所示:

$('.btnApplIdnDtls').click(function () {
    var rowCount = $('#tblApplIdn tr').length;
    var index = rowCount + 1;
    var IndentifyType=$('#TypeOfIdentification option:selected').text();//get values
    var IdentifyNum=$("#IdentityNumber").val();//get values
    var IssueDate=$('#IssueDate').val();//get values
    $('#tblApplIdn').append("<tr><td><input type='hidden' name='identitity.Index' value='" + index + "' /><input type='text'  name='identitity[" + index + "].TypeOfIdentification'></td><td><input type='text'  class='textreq' name='identitity[" + index + "].IdentityNumber'></td><td><input type='text'  class='textreq'  name='identitity[" + index + "].IssueDate'></td><td><input type='button' name='remove' class='remove' value='Remove' id='" + index + "'/></tr>");//simply append it
    var lasttr=$('#tblApplIdn tr:last'); //get the last tr
    lasttr.find('td:first input[type="text"]').val(IndentifyType); give its input a value
    lasttr.find('td:nth-child(2) input').val(IdentifyNum);
    lasttr.find('td:nth-child(3) input').val(IssueDate);
});
$('.btnApplIdnDtls')。单击(函数(){
var rowCount=$('#tblApplIdn tr')。长度;
var指数=行数+1;
var IdentificationType=$(“#TypeOfIdentification选项:selected”).text();//获取值
var IdentifyNum=$(“#IdentityNumber”).val();//获取值
var IssueDate=$('#IssueDate').val();//获取值
$('#tblApplIdn')。附加(“”;//只需附加它
var lasttr=$('#tblApplIdn tr:last');//获取最后一个tr
lasttr.find('td:first input[type=“text”]”)val(IdentificationType);为其输入指定一个值
lasttr.find('td:n个子(2)输入').val(identifNum);
lasttr.find('td:nth child(3)input').val(IssueDate);
});

您引用的代码不正确。@BhojendraNepal您能否按照您在回答部分所说的示例发布引用代码,如果这符合我的要求,我会将其标记为已接受。谢谢应该是这样的:)name=“identity['”+index+“']].TypeOfIdentification“@BhojendraNepal name在这里做什么。你能检查元素,然后检查这个按钮id=”“+index+它是什么吗???