<c:forEach items="${list}" var="list">
<input type="hidden" name="msel" value="${list.id}"/>
</c:forEach>
<div>
<select name="sel" id="sel">
<option></option>
</select>
</div>
怎么把forEach中获得的那个值${list.id}填到下面的下拉列表中呢?谢谢!
如果用js的话://获得list的值
function getSelect(){
var msel = document.getElementsByName("msel");
for(var i=0;i<msel.length;i++){
//下面不知道怎么办了
}
}
<input type="hidden" name="msel" value="${list.id}"/>
</c:forEach>
<div>
<select name="sel" id="sel">
<option></option>
</select>
</div>
怎么把forEach中获得的那个值${list.id}填到下面的下拉列表中呢?谢谢!
如果用js的话://获得list的值
function getSelect(){
var msel = document.getElementsByName("msel");
for(var i=0;i<msel.length;i++){
//下面不知道怎么办了
}
}
var msel = document.getElementsByName("msel");
var sel = document.getElementById("sel");
for(var i=0;i<msel.length;i++){
var option = document.createElement("option");
option.value = msel[i].value;
option.text = msel[i].value;
+'\v1' ? sel.add(option,null): sel.add(option);
}
}
谢谢!但是关于这个我需要用到的东西需要到哪里去查找呢。。例如:
option.value = msel[i].value;
option.text = msel[i].value;
这种我要到哪个api中去查找呢!
www.w3school.com.cn里面似乎就有