问下ajax的下拉菜单的问题

wangji131 2009-04-27 01:44:31
我现在的要在jsp实现的功能是实现一个下拉框,比如说页面展现name,选择后,传递值为id,实现不了,不知道ext里面怎么写,请大家帮忙下
我是用spring和dwr从service取值,service是这么写的:
public CoreDept[] getdepts() {
CoreDept[] depts = this.getAll().toArray(new CoreDept[]{});
return depts;
}


jsp页面:

<script src="${ctx}/dwr/interface/kzcFilialeService.js" type="text/javascript"></script>
<script type="text/javascript">
Ext.onReady(function(){
//alert(kzcFilialeService.getdepts);
kzcFilialeService.getdepts(function(typeList){
alert(typeList);//这里typeList:就是service返回的depts。取得到值,是一个数组
for(var i=0;i<typeList.length;i++){
//mytype[i] = [typeList[i]];
alert(typeList[i].deptname+"--")//这里取不到值,
}



}

alert(typeList+"----");
var store = new Ext.data.SimpleStore({
fields: ['oid','deptname','depttype'],//这里我Coredept的属性,这里的写法不知道错没有
data : typeList
});
alert(store+"-----");

//下面的报错。
var fs=new Ext.form.ComboBox({
store: store,
hiddenName :'oid',
displayField:'deptname',
triggerAction: 'all',
mode:'local',
selectOnFocus:true,
width:135,
applyTo:'filoid'
});*//*
});
});
</script>



<tr>
<td class="propLable">所属分公司:</td>
<td><ww:textfield name="filoid" cssStyle="width:100%" /></td><td><font color="red">*</font></td></tr>

...全文
176 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Defonds 2009-05-04
  • 打赏
  • 举报
回复
我的资源里有个jsp版AJAX下拉菜单级联源码
有需要的朋友可以去看看
2到20个英文 2009-05-04
  • 打赏
  • 举报
回复
路人,顶下~~
valen_jia 2009-05-03
  • 打赏
  • 举报
回复
EXT不会,要是jquery可以帮你,帮你顶下
w382572397 2009-05-03
  • 打赏
  • 举报
回复
用 编译器 调试一下
wanghao1987 2009-05-03
  • 打赏
  • 举报
回复
取select的DOM对象,用它加option
jxplus 2009-05-03
  • 打赏
  • 举报
回复
给你个建议:在页面写个空<select></select>,然后写个js方法,用传来的值给<select>加option,如
select.innerHTML="<option value='id'>name</option><option value='id'>name</option>...";
再在页面载入时,执行这个方法,这样应该能实现你的问题吧。

81,092

社区成员

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

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