0
设定值输入我有这样的HTML代码,显示一个表格为什么无法使用JavaScript
<table id="tabel-item-borrowed" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th class="headtabel">Categories</th>
<th class="headtabel">Description</th>
<th class="headtabel">Action</th>
</tr>
</thead>
<tbody>
<tr id="t11">
<td>
<input id="catinfo[1]" type="text" name="catinfo1" size="40">
<input id="categories[1]" type="text" name="categories1" size="40">
</td>
<td>
<input id="description[1]" type="text" name="description1" size="40">
</td>
<td>
<input id="delete[1]" type="button" name="delete" value="delete" size="5">
</td>
</tr>
<tr id="t12">
<td>
<input id="catinfo[1]" type="text" name="catinfo1" size="40">
<input id="categories[2]" type="text" name="categories2" size="40">
</td>
<td>
<input id="description[2]" type="text" name="description2" size="40">
</td>
<td>
<input id="delete[2]" type="button" name="delete" value="delete" size="5">
</td>
</tr>
</tbody>
</table>
我想用JavaScript来充实内心<input id="catinfo[1]" type="text" name="catinfo1" size="40">
值。这是我的代码
,这JavaScript来填补PHP函数值转换成HTML输入
$("input#idposinfo").val('');
$("input#categories\\[" + lastrow + "\\]").val(category);
$("input#description\\[" + lastrow + "\\]").val(description);
//succes fill the value inside catinfo
//$("input#catinfo\\[" + lastrow +"\\]").val(category);
$.post("get_category_info/" + $('#combocategory1').val() + "/" + $('#combocategory2').val(), {}, function (obj) {
console.log("get obj value");
console.log(obj); //value in obj is int 25
$("input#catinfo\\["+lastrow+"\\]").val(obj);
console.log("success get obj value");
});
lastrow++;
$("input#lastrow").val(lastrow);
内$。员额中,$("input#catinfo\\[" + lastrow +"\\]").val(category);
没有工作
我如何填写价值从$.post
?
'lastrow'的价值是什么?我在问这是因为你在异步调用之外递增它。 –