我在页面上有三个jQuery UI“自动填充”输入字段:
<select id="combobox1"><?php putSome1ValuesHere(); ?></select>
<select id="combobox2"><?php putSome2ValuesHere(); ?></select>
<select id="combobox3"><?php putSome3ValuesHere(); ?></select>
将它们全部组合成组合框可以正常工作:
$(function() {
$( "#combobox1" ).combobox();
$( "#combobox2" ).combobox();
$( "#combobox3" ).combobox();
});
我想要做的是根据在组合框中选择的值重定向到另一个页面。如果我将其中一个明确命名为
,则此方法可以正常工作select: function( event, ui ) {
ui.item.option.selected = true;
that._trigger( "selected", event, {
item: ui.item.option
});
window.location.href = $('#combobox1').val() + ".php";
},
我不能做的是根据点击的组合框的值重定向。我无法硬连线,因为可以点击三个盒子中的任何一个。但是,我只是不太了解jQuery来访问已调用'select'函数的框的值。我很感激任何人都可以提供的建议。我想我上面已经包含了足够的信息,但是如果需要的话请告诉我。谢谢!
答案 0 :(得分:0)
select
中的是隐藏的选择标记的jQuery对象
window.location.href = select.val() + ".php";
使用select.val()
http://jsfiddle.net/YBFAr/
答案 1 :(得分:0)
更改此
select: function( event, ui ) {
ui.item.option.selected = true;
that._trigger( "selected", event, {
item: ui.item.option
});
window.location.href = $('#combobox1').val() + ".php";
},
到
select: function( event, ui ) {
ui.item.option.selected = true;
that._trigger( "selected", event, {
item: ui.item.option
});
window.location.href = $(this).val() + ".php";
},
希望这有帮助