select onclick="selectData(this)" option value="" --参考名称--/option c:forEach items="${allSimpleLineName }" var="name" option value="${name}" ${name}/option /c:forEach /select 相关js script type="text/javascript" function selectData
<option value="" >--参考名称--</option>
<c:forEach items="${allSimpleLineName }" var="name">
<option value="${name}" >${name}</option>
</c:forEach>
</select>
相关js
<script type="text/javascript">function selectData(obj){
var targetV = $(obj).val();
$("input[name='czzd']").val(targetV);
}
</script>
相关sql
<select id="getAllSimpleLineName" resultType="String">select f_simplelinename from W_EC_ELECTRIC_CURRENT t group by f_simplelinename
</select>
java方法
dao
public List<String> getAllSimpleLineName(){return this.getBySqlKeyGenericity("getAllSimpleLineName",null);
}
service
public List<String> getAllSimpleLineName(){return dao.getAllSimpleLineName();
}
controller
)@Action(description="编辑珠数据管理")
public ModelAndView edit(HttpServletRequest request) throws Exception
{
Long id=RequestUtil.getLong(request,"id");
String returnUrl=RequestUtil.getPrePage(request);
ZhDlbSjgl zhdlbsjgl=zhdlbsjglService.getById(id);
List<String> allSimpleLineName = zhdlbsjglService.getAllSimpleLineName();
return getAutoView().addObject("zhdlbsjgl",zhdlbsjgl).addObject("allSimpleLineName",allSimpleLineName)
.addObject("returnUrl",returnUrl);
}