当前位置 : 主页 > 编程语言 > java >

下拉框,循环输出option

来源:互联网 收集:自由互联 发布时间:2022-09-02
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
<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(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);
}

 

上一篇:js之关闭/刷新窗口相关代码
下一篇:没有了
网友评论