我已经使用类型(选择)、名称(文本)、单位(选择)创建了动态行,我正在为更改类型的选择编写代码。但是,当我从类型字段中更改值时,它已将值加载到当前行名称字段中,并将选项动态加载到当前单元选择字段中,将值加载到活动行中工作正常,但将选项加载到选择单元中则不行。我的代码如下$(document).on('change', '.raw', function () { // var r = this.val(); if ($(this).val() != 0) { var t = $(this).parents('tr').find(".raw :selected").text(); $(this).parents('tr').find(".name").val(t);我需要帮助的地方如下$(this).parents('tr').find(".amount").html(data); -> here i need help// $(".amount").html(data); ->this working fine but change all the select value提前致谢。这是我的表的完整编码<table id="addingtable" class="table table-bordered"><tr> <th>Raw Master</th> <th>Name</th> <th>Display</th> <th>Value</th> <th>Unit</th> <th>Delete</th></tr><tr> <td><select name='rawmaster[]' class = 'form-control raw' required><option>Select</option><?php echo rawmaster_item($conn,$type); ?><option value="0">None</option></select></td> <td><input type='text' name='name[]' placeholder="Name" class = 'form-control name' required /></td> <td><select name='des[]' class = 'form-control' required><option>Select</option><option Value = 'y'>Yes</option><option Value = 'n'>No</option></select></td> <td><input type='text' name='value[]' placeholder="Value" class = 'form-control' required /></td> <td><select name='amount[]' class = 'form-control amount' required><option>Select</option><?php echo $output2; ?></select></td> <td><button type='button' class='btn btn-icon btn-danger remove'><i class='feather icon-trash-2'></i></button></td></tr>
1 回答
![?](http://img1.sycdn.imooc.com/533e4c5600017c5b02010200-100-100.jpg)
ABOUTYOU
TA贡献1812条经验 获得超5个赞
我可能错了,但我认为您需要在 ajax 请求上设置上下文,否则this将引用不同的上下文(回调),添加context:this如下:
$.ajax({
url:"plandetails_getunit.php",
method:"POST",
data:"id="+r,
context:this,
success:function(data)
{
- 1 回答
- 0 关注
- 95 浏览
添加回答
举报
0/150
提交
取消