Code对象?Code对象有id和name属性?用C标签吧,会方便点
格式如下:
<select name="" id="" onchange="">
<c:forEach items="${codeList}" var="code">
<option value="${code.id}">${code.name}</option>
</c:forEach>
</select>
var row = ('${listType}'.split(",")).lengthvar select = "<select name='dutyChildType'>"
for (var i = 0 i < row i++) {
var dutyId = "${listType[" + i + "].dutyId}"
var dutyTypeName = "${listType[" + i + "].dutyTypeName}"
select += "<option value='" + dutyId + "'>" + dutyTypeName + "</option>"
}
select += "</select>"
1、首先输入下方中的代码:
var obj = document.getElementByIdx_x(”testSelect”)//定位id
var index = obj.selectedIndex// 选中索引
2、然后继续输入下方中的代码:
var text = obj.options[index].text// 选中文本
var value = obj.options[index].value// 选中值
3、最后运行了就可以获取到select的option值了,效果图: