0
请参阅图像我正在尝试执行的操作我在每个td中都有HTML表格我有下拉菜单和复选框,当我在下拉列表中选择值时我想要使复选框检查特定的td任何人都可以指导我如何做到这一点。如何在选择下拉菜单时选中该复选框
代码:
<td style="width:141px" > <select name="mySelect" id="mySelect" class="edit1 route '.$rows["net_id"].'" >
<option value="-1">Choose..</option>';
$query = "SELECT route FROM routestable WHERE `clientid` = '$client_id' ";
$result = mysql_query($query);
while ($rows1 = mysql_fetch_assoc($result))
{
if(strlen($rows1['route'])>0 && $rows1['route']==$rows['route']){
print' <option value="'.$rows1['route'].'" selected>'.$rows1['route'].' </option>';}
else{
echo '<option value="' . $rows1['route'] . '"> ' . $rows1['route'] . '</option>';
}
}
echo '</select>
</td>
<td style="width:200px" id="CPH_GridView1_Status1'.$rows['net_id'].'" class="edit2 status1 '.$rows["net_id"].' "><input type="checkbox" style="margin:0 0 0 93px;" name=""/></td>
AJAX
<script>
$(document).ready(function(){
$('.edit1').on('change', function(){
arr = $(this).attr('class').split(" ");
var clientid=document.getElementById("client").value;
account_id=document.getElementById("account_id").value;
$.ajax({ type: "POST",
url:"clientnetworkpricelist/routestatusupdate.php",
data: "value="+$(this).val()+"&rowid="+arr[2]+"&field="+arr[1]+"&clientid="+clientid+"&account_id="+account_id,
success: function(res){
data = jQuery.parseJSON(res); //added line
alert('Saved Successfully!');
$('#CPH_GridView1_Status'+arr[2]).empty();
$('#CPH_GridView1_Status'+arr[2]).append(data.status);
$('.ajax').html($(this).val());
$('.ajax').removeClass('ajax');
}});
}
);
});
</script>
在ajax请求之前的变更句柄中,尝试'$(this).closest('td')。next()。find('input')。prop('checked',true) –