package test1;import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;public class Test15 {
public static void main(String[] args){
Map map=new HashMap();
map.put("Aa", "查询记录");
map.put("Ab", "修改记录");
map.put("Ac", "删除记录");
Iterator it=map.keySet().iterator();
StringBuffer sb=new StringBuffer();
sb.append("<select name=\"list1\" size=\"10\" multiple class=\"option\"> ");
while(it.hasNext()){
String temp=(String)it.next();
sb.append("<option value='").append(temp)
.append("'>").append((String)map.get(temp)).append("</option>");
}
sb.append("</select>");
System.out.println(sb.toString());
}
}
把System.out换成out
解决方案 »
- ExtJs搜索功能问题
- javaScript错误: ‘firstChild’为空或不是对象
- iframe嵌入第三方网页,如何限制第三方页面替换parent页面
- javascript如何在本页面传值
- 求一个正则表达式,谢谢
- 奇怪的问题,网页重定向之后不会自动更新了
- 请教完美动态下拉列表框如何实现数据的接送?工作中,急,请帮忙!
- window.open或onload的问题,在线等待
- 新年礼物:小游戏(1),答对着得150分,参与者也有分!答案最简单者得高分![IE6实现即可] [请进……]
- 各位大虾,如何在页面制作带有滚动条的表格?急!急!!!
- js根据list生成select 50分
- 谁有MzTreeView 2.0和应用实例给偶发一份,谢谢了!!!!
不好意思
我没有说明白
我的map集合是通过dwr直接调用java class的方法得到的
也就是我需要用js来动态生成此select
<script language=javascript>
var temp=new Array()
temp[temp.length]='<select name="list1" size="10" multiple class="option"> '
map={"Aa": "查询记录","Ab":"修改记录","Ac": "删除记录"}
for(var i in map){
temp[temp.length]="<option value='"
temp[temp.length]=i
temp[temp.length]="'>"
temp[temp.length]=map[i]
temp[temp.length]="</option>"
}
temp[temp.length]="</select>"
document.getElementById("div1").innerHTML=temp.join("")
</script>
能给我解释一下for循环里面的js代码么?
我不了解js
还有那个map集合,在js中也有?
我现在要下班了
麻烦你了
这里的MAP好比枚举型变量