html代码:
<tr class="item-row">
<td>
<input type="button" class='del' value="" style="z-index:16; background-image:url(../images/delete.png); background-repeat:no-repeat; background-position:left center; text-align:right;"/>
</td>
<td>
<input type="button" name="pilihItem[]" value="i" id="pilihItem" class="pilihItem">
</td>
<td>
<input type="text" id="nama_item" name="nama_item[]" value="" style="width: 200px;">
</td>
</tr>
<tr class="item-row">
<td>
<input type="button" class='del' value="" style="z-index:16; background-image:url(../images/delete.png); background-repeat:no-repeat; background-position:left center; text-align:right;"/>
</td>
<td>
<input type="button" name="pilihItem[]" value="i" id="pilihItem" class="pilihItem">
</td>
<td>
<input type="text" id="nama_item" name="nama_item[]" value="" style="width: 200px;">
</td>
</tr>
打开子窗口的jquery代码:
$("#pilihItem").click(function(){
var id = 1;
var name = $(this).prev().attr("name");
var url = "../formItem.php?id=" + id + "&name=" + name;
window.open(url, 'Pilih Item', 'location=1,status=1,scrollbars=1,resizable=no,width=800,height=300');
});
将值设置为父窗口的 jquery 代码:
window.opener.$("#nama_item").val($.trim(nama_item));
问题:我无法设置单击按钮#pilihItem 的#nama_item 文本框的值。它总是在第一行设置文本框。任何帮助都感激不尽。