请看图像我正在尝试做什么我有每个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>
答案 0 :(得分:2)