jQuery UI 范围滑块值输入字段
使用 jQuery 范围滑块,我一直在尝试获取隐藏输入字段中的值,该输入字段将用于搜索。
隐藏的输入字段与滑块字段具有相同的 id,其中的值但隐藏的输入字段已显示任何内容!
$(document).ready(function() {
$( "#sliderranger" ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount1" ).val( "THB " + ui.values[ 0 ] );
$( "#amount2" ).val( "THB " + ui.values[ 1 ] );
var price1 = ui.values[ 0 ];
var price2 = ui.values[ 1 ];
//alert(price1 + " " + price2);
$( "#price1" ).value = price1;
}
});
$( "#amount1" ).val( "THB " + $( "#sliderranger" ).slider( "values", 0 ));
$( "#amount2" ).val( "THB " + $( "#sliderranger" ).slider( "values", 1 ));
});
上面是 js 代码,如果这有帮助,如果您需要更多信息,请告诉我,我看看我能做什么。
希望有人可以帮助我在这个主题上看到很多东西?
using the jQuery range slider i have been trying to get the values in a hidden input field which will be used for a search.
the hidden input field has the same id as the slider fields which the value but the hidden ones done show anything!
$(document).ready(function() {
$( "#sliderranger" ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount1" ).val( "THB " + ui.values[ 0 ] );
$( "#amount2" ).val( "THB " + ui.values[ 1 ] );
var price1 = ui.values[ 0 ];
var price2 = ui.values[ 1 ];
//alert(price1 + " " + price2);
$( "#price1" ).value = price1;
}
});
$( "#amount1" ).val( "THB " + $( "#sliderranger" ).slider( "values", 0 ));
$( "#amount2" ).val( "THB " + $( "#sliderranger" ).slider( "values", 1 ));
});
above is the js code if this helps if you need more info let me know and il see what i can do .
hope some one can help i can see much on this topic ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我希望您的值并不意味着同一页面上有两个具有相同
id
属性的元素。如果是这样,您需要更改此设置,否则您会看到意想不到的结果。至于使用滑块结果设置隐藏输入的值,看起来您已经很接近了。此行:
应更改为:
这是修改后的代码(并使用
text
类型的可见input
元素,而不是hidden
):http://jsfiddle.net/andrewwhitaker/Pyprr/I hope you don't mean that there are two elements with the same
id
attribute on the same page. If so, you'll need to change this or you'll see unexpected results.As for setting the value of hidden inputs with slider results, it looks like you're close. This line:
Should be changed to:
Here's your code revised (and using visible
input
elements of typetext
instead ofhidden
): http://jsfiddle.net/andrewwhitaker/Pyprr/