<SCRIPT language="javaScript">
var d = new dTree('d')
d.add(1,-1,"用户组","","","kunFrame")
<%
Object obj =request.getAttribute("custgrouplist")
List groupList = null
int count =2
String groupName = ""
int groupId = 0
if(obj!=null)
{
groupList = (List)obj
}
if(groupList!=null&&groupList.size()>0)
{
for(int i=0i<groupList.size()i++)
{
CustGroup am = (CustGroup)groupList.get(i)
groupName = am.getVgroupName()
groupId = am.getGroupId()
// System.out.println(groupId)
%>
d.add(<%=count%>,1,'<%=groupName%>','<%=request.getContextPath()%>/showAreaByGroup.action?groupId=<%=groupId%>',"","kunFrame")
<%
count++
}
}
%>
document.write(d)
</SCRIPT>
$.post('/wjdc/admin/wxWjTm/chooseTm.do', {wjId: wjId
}, function(res) {
// [{'id':'1','sxTm':'性别'},{'id':'2','sxTm':'省份'}]
var sel = $("select")
for (var i = 0 i < res.length i++) {
sel.append("<option value=" + res[i].id + ">" + res[i].sxTm + "</option>")
}
})
list集合中如果封装的是如字符串或者基本数据类型的数据,则可以通过list.toArray()转换成数组传到JS中读取,如果list集合中保存的是对象,则将对象转换成JSON类型的字符串保存在list集合中,在JS中读取时,先读取到字符串,再将字符串转换为JSON对象处理就行了。