List<>集合绑定到select控件

zhouwei7682719 2011-10-25 06:36:20
<%
foreach (var comm in commonList)
{
%>
<option value="<%=comm.QuestionID%>"><%=comm.QuestionName%></option>
<%
}
%>


function questionVal()
{
for (var i = 0; i < document.getElementById("Question1").options.length; i++) {
if(document.getElementById("Question1").options[i].value == document.getElementById("Question2").options[i].value)
{
document.getElementById("Question2").options[i].remove;
document.getElementById("Question3").options[i].remove;
}
}
}
js中怎么把这个List<> 绑定到<select name="Question2" onchange="questionVal()" style="width:153px;">
...全文
178 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
happy664618843 2011-10-26
  • 打赏
  • 举报
回复
list<model> list=new list<model>();
foreach(model t in list){
}
Seek_you 2011-10-25
  • 打赏
  • 举报
回复
研究研究
豆虫 2011-10-25
  • 打赏
  • 举报
回复
${comm.QuestionName}>
呃~~~多了个大于号
豆虫 2011-10-25
  • 打赏
  • 举报
回复
后台将List存到request中去
request.setAttribute('commonList',你的list);


前台jsp中使用c标签的foreach循环:
<select>
<c:forEach var="comm" items="${commonList}">
<option value="${comm.QuestionID}">${comm.QuestionName}></option>
</c:forEach>
</select>
zhouwei7682719 2011-10-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 fanchuanzhidu 的回复:]

那个foreach用的不对吧 那个是jstl的<c:foreach>标签的用法 jsp中没有直接foreach的
[/Quote] 亲,就告诉俺 这么把list<>集合绑到select控件吧!
gmemai 2011-10-25
  • 打赏
  • 举报
回复
我感觉这个要求跟jsf的实现一样的,感觉楼主如果要绑定的话就要从后台读取数据自己设置到select中,提交的时候要自己再设进去
豆虫 2011-10-25
  • 打赏
  • 举报
回复
那个foreach用的不对吧 那个是jstl的<c:foreach>标签的用法 jsp中没有直接foreach的
zhouwei7682719 2011-10-25
  • 打赏
  • 举报
回复
看标题就行 其实;

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧