在一组动态生成的<select>表单元素中利用动态ID 定位元素
$(‘#driver_confirm‘).live(‘click‘, function() {
var autoOrderid = $(this).attr(‘data-autoOrderid‘);
//alert(autoOrderid);
//alert($(‘select[name=day‘+autoOrderid+‘]‘).val());
//return false;
var date = $(‘select[name=day‘+autoOrderid+‘]‘).val();//name 是带有day前缀+id生成的
var time = $(‘select[name=time‘+autoOrderid+‘]‘).val();
var driverid=<?php echo $driverid;?>;
$.ajax({
type : ‘post‘,
url : ‘/orderExtend/driver_confirm‘,
data : {"driverid" : driverid, "autoOrderid" : autoOrderid},
success : function(data) {
alert(data)
if(data == 1) {
alert(‘成功指派物流车辆,司机将收到系统提示!‘);
var url = "/empOrder/emp_manage";
window.location.href = url;
} else {
alert(‘发生错误!‘);
}
}
});
});