+ -
当前位置:首页 → 问答吧 → jquery cascade select 取值

jquery cascade select 取值

时间:2011-07-22

来源:互联网

我利用jquery套件做连动选单
选第一层之后再选第二层再选第三层
问题出现
选第一层后可以正常显示第二层出来
但是要选第二层然后出现第三层时会有问题
因为我第三层的值会根据第一层与第二层的值去捞资料库
在选第二层时我利用 select1: $('#select1').val()去取得第一层的值却一值出现0
不知到选第二层时如何取得第一层的值
谢谢!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//第1阶层对应第2阶层 $('#select2').cascade('#select1', { ajax: { type: "post", url: 'AjaxSelectServlet', data: { lv: '2', val: $('#select1').val() }, dataType: "json" }, template: function(item) { return "<option value='" + item.Value + "'>" + item.Text + "</option>"; }, match: function(selectedValue) { return this.When == selectedValue; } });
//第2阶层对应第3阶层 $('#select3').cascade('#select2', { ajax: { type: "post", url: 'AjaxSelectServlet', data: { lv: '3', select1: $('#select1').val(),val: $('#select2').val()}, dataType: "json" }, template: function(item) { return "<option value='" + item.Value + "'>" + item.Text + "</option>"; }, match: function(selectedValue) { return this.When == selectedValue; } });
 

作者: kevin524   发布时间: 2011-07-22

看不出来有什么不对
不过我对select一向不太相信直接取value
如果你用
$('#select1 option:selected').val()
取代
$('#select1').val()
试试看咧?

作者: kenshin520   发布时间: 2011-07-23