我在每个td里面都有html表我有下拉列表,看下面的图像是什么样的
如果我在第二个td的下拉列表中选择1201,我也想将其值更改为具有相同ID的其他下拉列表,如果id不匹配则不会更改
<td style="width:141px" id="CPH_GridView1_route'.$rows['net_id'].'" >
<select name="mySelect" id="mySelect" class="edit1 route '.$rows["net_id"].'" >
<option value="-1">Choose..</option>';
<option value="-1">1201</option>';
<option value="-1">1101</option>';
</select>
</td>
AJAX
<script>
$(document).ready(function(){
$('.edit1').on('change', function(){
$.ajax({ type: "POST",
url:"xxxxx/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_route').empty();
$('#CPH_GridView1_route').append(data.routeupdate);
$('.ajax').html($(this).val());
$('.ajax').removeClass('ajax');
}
});
});
});
</script>
答案 0 :(得分:0)
<select name="mySelect" id="mySelect" class="edit1 route '.$rows["net_id"].'" onChange="foo()">
<option value="-1">Choose..</option>';
<option value="-1">1201</option>';
<option value="-1">1101</option>';
</select>
<select name="second" id="mySelect" >
<option value="-1">Choose..</option>';
<option value="-1">1</option>';
<option value="-1">2</option>';
</select>
<script>
function foo(){
alert("cahnge");
document.getElementById("div1').innerHTML="<select name="second" id="mySelect" >
<option value="-1">Choose..</option>';
<option value="-1">1</option>';
<option value="-1">2</option>';
</select>";
}
</script>