<select onchange="lxx(this)">
<option value="">全部</option>
<option value="水电" <c:if test='${lx=="水电"}'>selected=selected</c:if> >水电</option>
<option value="火电" <c:if test='${lx=="火电"}'>selected=selected</c:if>>火电</option>
<option value="风电" <c:if test='${lx=="风电"}'>selected=selected</c:if>>风电</option>
<option value="光伏" <c:if test='${lx=="光伏"}'>selected=selected</c:if>>光伏</option>
</select>
function updateWczZt(obj) {
var zt = $(obj).val();
var msg = '';
if (zt == '' || zt == null || zt == 'N') {
msg = "移除误差?";
zt = "N";
} else {
msg = "添加错差?";
zt = "Y";
}
$.ligerDialog.confirm(msg, function(yes) {
if (yes) {
var id = $("input[name='id']").val();
var url = __ctx + "/yjdlfh/yjdlfh/yjdlfhzb/updateWczZt.ht";
var params = {
id : id,
zt : zt
}
$.ajax({
url : url,
data : params,
type : "post",
async : true,
success : function(rtn) {
if (rtn == "true") {
$.ligerDialog.success("修改成功");
var tjrq = $("input[name='rq']").val();
location.href = __ctx
+ "/yjdlfh/yjdlfh/yjdlfhzb/edit.ht?tjrq="
+ tjrq;
} else {
$.ligerDialog.alert("修改失败");
}
},
error : function() {
$.ligerDialog.alert("修改失败");
}
});
}
});
}
扩展(个人收藏)
@ResponseBody
@RequestMapping("updateWczZt")
public String updateWczZt(HttpServletRequest request, HttpServletResponse response) {
String isSuc = "false";
Long id = RequestUtil.getLong(request, "id");
logger.info("id是否为空====" + id);
String zt = RequestUtil.getStringValues(request, "zt");
logger.info("zt 是否为空====" + zt);
Yjdlfhzb e = yjdlfhzbService.getById(id);
if (e != null) {
e.setZt(zt);
yjdlfhzbService.update(e);
isSuc = "true";
}
return isSuc;
}
扩展2 java
<select onchange="changeState(this,${hydwzdgzjhoneItem.id})">
<option value="">未选择</option>
<option value="进行中" <c:if test='${hydwzdgzjhoneItem.zt=="进行中"}'>selected=selected</c:if>>进行中</option>
<option value="已完成" <c:if test='${hydwzdgzjhoneItem.zt=="已完成"}'>selected=selected</c:if>>已完成</option>
<option value="已延期" <c:if test='${hydwzdgzjhoneItem.zt=="已延期"}'>selected=selected</c:if>>已延期</option>
<option value="未开展" <c:if test='${hydwzdgzjhoneItem.zt=="风电"}'>selected=selected</c:if>>未开展</option>
</select>
复制用html
function changeState(obj,id) {
var zt = $(obj).val();
// $.ligerDialog.confirm(msg, function(yes) {
// if (yes) {
// alert(id);
var id = id;
var url = __ctx + "/hydlbbzdgz/hydlbbzdgz/hydwzdgzjhone/updateState.ht";
var params = {
id : id,
zt : zt
}
$.ajax({
url : url,
data : params,
type : "post",
async : true,
success : function(rtn) {
if (rtn == "true") {
$.ligerDialog.success("修改成功");
// var tjrq = $("input[name='rq']").val();
// location.href = __ctx + "/yjdlfh/yjdlfh/yjdlfhzb/edit.ht?tjrq=" + tjrq;
location.href = __ctx + "/hydlbbzdgz/hydlbbzdgz/hydwzdgzjhone/list.ht";
} else {
$.ligerDialog.alert("修改失败");
}
},
error : function() {
$.ligerDialog.alert("修改失败");
}
});
// }
// });
}
复制用js
@ResponseBody
@RequestMapping("updateState")
public String updateWczZt(HttpServletRequest request, HttpServletResponse response) {
String isSuc = "false";
Long id = RequestUtil.getLong(request, "id");
logger.info("id是否为空====" + id);
String zt = RequestUtil.getStringValues(request, "zt");
logger.info("zt 是否为空====" + zt);
Hydwzdgzjhone e = hydwzdgzjhoneService.getById(id);
if (e != null) {
e.setZt(zt);
hydwzdgzjhoneService.update(e);
isSuc = "true";
}
return isSuc;
}
复制用java
function() {
$('.changeState').each(function(){
var state = $(this).val();
var color = "";
if(state=="进行中"){
color="blue";
}else if(state=="已完成"){
color="green";
}else if(state=="已延期"){
color="red";
}else if(state=="未开展"){
color="yellow";
}
$(this).css("background-color",color);
$(this).css("font-size","12px");
if(color!=""){
$(this).css("border","0px");
$(this).css("color","white");
}
});
});
复制用js-根据选中的值添加不同颜色