Wednesday, 15 September 2010

javascript - Drag Range Slider - How to add step and an element (comma) to the output -



javascript - Drag Range Slider - How to add step and an element (comma) to the output -

i'm using dragdealer.js , have got far:

fiddle

while dragging through slide, gives output,

question: 1) how can add together "," (comma) output after hundreds unit while dragging?

-> right now:-$ 4023 -> required output:- $ 4,023

2) how implement step shows output in multiple of 100?

-> required output:- $ 4.100 (multiple of 100)

here code:

js:

$(function() { new dragdealer('just-a-slider', { animationcallback: function(x, y) { $('#dragvalue').text(math.round(x * 15000)); } }); var availheight = $('.content-body').outerheight() - $('.content-mask').outerheight(); new dragdealer('content-scroller', { horizontal: false, vertical: true, yprecision: availheight, animationcallback: function(x, y) { $('.content-body').css('margin-top', -y * availheight); } }); });

you can utilize .replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") add together in comma, , if split base of operations 100, ( = 150 ), step through in 100's , can append additional 0's onto text output required.

see fiddle here : http://jsfiddle.net/535pd/4/

javascript jquery

No comments:

Post a Comment