Adjustable bars connected as a group, value in textfields
I w开发者_开发问答ant 5 bars that are connected in the way that the total value of hem is 100%
ex user moves bar 1 up 4% and bar 2,3,4,5 moves down 1% each.
the values should be projected in textfields so the form can be POSTed for some PHP operations.
I have seen this on webapplications before and just assume it is javascript. does anone know how it is done?
thanks a lot!
Those "bars" are usually called "sliders". Most popular libraries have a class for such control. Here's a slider, I've written once: http://www.zavoevately.ru/js/slider.js You can use it, if you're not going to directly sell parts of this code.
It requires Mootools for some functions, but works in quirksmode and have "cut" feature:
E.g. you have a scale from 0 to 100, but values only from 0 to 50 should be chosen. It will be useful for some combinations of values for several bound sliders.
You'll need to call setValue
for all sliders except that one, in which it was called in order to keep their values bound.
the values should be projected in textfields
just add code which will update textfield into change function — change property in third argument in constructor. Also may will need a nethod for updatind _max_cut
and _min_cut
and re-initializing all dependant values.
You may do the similar thing with YUI slider, which is more popular, versatile and is supported =)
精彩评论