How to realize range slider using jQuery
来源:互联网 发布:叫出租车的软件 编辑:程序博客网 时间:2024/05/29 03:40
/*by Jiangong SUN*/
Here is an sample for my project which is realized using aspx and jquery slider library.
$(document).ready(function () { //centralised slider code var stepvalues = ["0", "3000", "5000", "8000", "12000", "15000", "20000", "25000", "30000", "40000", "50000"]; var minRange = 0; var maxRange = 50000; //var range = '<%#WebContext.Current.User.PropertiesInternaute["+Elementcatalogue_montant"] != null ? WebContext.Current.User.PropertiesInternaute["+Elementcatalogue_montant"] : "" %>'; if (range != '') { var valmin = range.split('$')[0].replace(/\s+/g, ""); var valmax = range.split('$')[1].replace(/\s+/g, ""); } else { var valmin = 0; var valmax = 50000; } $("#slider-range").slider({ range: true, min: 0, //minimum value max: 10, //maximum value step: 1, //step values: [valmin, valmax], start: function (event, ui) { var valueL = $(this).slider('option', 'values')[0].toString().replace(/\s+/g, ""); var valueR = $(this).slider('option', 'values')[1].toString().replace(/\s+/g, ""); if ($.inArray(valueR, stepvalues) != -1) { ui.values[1] = $.inArray(valueR, stepvalues); $(this).slider('option', 'values')[1] = $.inArray(valueR, stepvalues); } if ($.inArray(valueL, stepvalues) != -1) { ui.values[0] = $.inArray(valueL, stepvalues); $(this).slider('option', 'values')[0] = $.inArray(valueL, stepvalues); } }, slide: function (event, ui) { var minvaleur = stepvalues[ui.values[0]]; var maxvaleur = stepvalues[ui.values[1]]; $("#amount").val(minvaleur + " $ " + maxvaleur); $("a.ui-slider-handle").empty(); $('a.ui-slider-handle').eq(0).append(minvaleur); $('a.ui-slider-handle').eq(1).append(maxvaleur); } }); if (range != '') { minRange = range.split('$')[0]; maxRange = range.split('$')[1]; } var positionL = $.inArray(minRange.toString().replace(/\s+/g, ""), stepvalues) * 10; var positionR = $.inArray(maxRange.toString().replace(/\s+/g, ""), stepvalues) * 10; $('a.ui-slider-handle').eq(0).append(minRange); $('a.ui-slider-handle').eq(0).css('left', positionL + '%'); $('a.ui-slider-handle').eq(1).append(maxRange); $('a.ui-slider-handle').eq(1).css('left', positionR + '%'); $('a.ui-slider-handle').eq(1).addClass("maxinfo"); $("#amount").val(minRange + " $ " + maxRange); //get new position for handles if (range != null && range.length > 0 && range != '') { var min = $.inArray(minRange.toString().replace(/\s+/g, ""), stepvalues); var max = $.inArray(maxRange.toString().replace(/\s+/g, ""), stepvalues); $("#slider-range").slider('option', 'values', [min, max]); }});
Enjoyr coding!
- How to realize range slider using jQuery
- How to Realize RPC?
- use slider to realize the button function
- How to realize the UIView convert to UIImage?
- How to Realize the Two's Complement of -128?
- Learn How To Realize Positive Risk Response Strategies (Opportunities)
- how to install jQuery profile on eclipse using Spket
- How to load all files from directory using JQuery ?
- How to Using exploits.
- How to using TOR
- HOW TO: Using CVS
- How to Using Theano
- How to configure Apache and Tomcat to realize the load balancing?
- jQuery的范围滑块Ion.Range Slider
- jQuery 实现table卷轴移动(How to scroll to specific item using jQuery?)
- LightSwitch how to realize two combobox linkage(如何实现2个下拉框联动)
- How to get random number within a range using C++ - 如何用C++获取一定范围内的随机数
- csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net C
- (Windows Form)两个打开的窗体之间相互调用。
- Word2003取消首字母大写方法
- 序号的结构层次顺序
- 输出一个字符串中没有重复的字符。如“baaca”输出“bac”。
- poj 3683 2-sat
- How to realize range slider using jQuery
- 百度词条的填充
- Unity--A simple way of fading a Texture2D
- linux服务器集群重复批量维护脚本实现
- WinForm开发 DataGridView控件的各种操作总结(三、针对datagridview全局属性的设置)
- 嵌入式开发的几个基本问题
- android ace绘制饼图
- ASCII码表
- CentOS安装Hadoop并运行WordCount实例