ManuW
Junior Member
Posts: 2
Registered: 12/12/2007
Location: Austria
Member Is Offline
|
| posted on 12/13/2007 at 12:00 AM |
|
|
Limit for sum of multiple sliders' values.
Hello there,
I first want to thank you for this cool tool. It's really nice.
Now, maybe someone can help me.
I have three sliders in one form. The user can mixture some ingredients together, so that the sum of all three sliders' values may not exceed
100%.
How can I set this limit, so that the user can't raise the values if it is reached?
Thanks in advance for your help. Sincerely,
-Manuel
|
|
|
ManuW
Junior Member
Posts: 2
Registered: 12/12/2007
Location: Austria
Member Is Offline
|
| posted on 12/13/2007 at 11:14 PM |
|
|
I found a very easy way.
I modified the function f_sliderSetValue() by adding following lines at the end right after "e_input.value = n_value;"
var tmpSum = 0;
for(var i = 0; i < A_SLIDERS.length; i++) {
tmpSum += A_SLIDERS.n_value;
}
if(tmpSum > 100) {
this.f_setValue(n_value - 10);
}
This can surely be implemented more elegant, but it works. ;-)
Greetings.
-Manuel
|
|
|
mdzoidberg
Newbie
Posts: 1
Registered: 3/25/2008
Location: USA
Member Is Offline
|
| posted on 3/26/2008 at 12:02 AM |
|
|
Hi, not sure if you still keep track of this forum, is there any way for you to give more insight as to how apply your code to limit the sum of
multiple sliders, i tried your extra code but is not doing the trick, any help is appreciated, thanks.
| Quote: | Originally posted by ManuW
I modified the function f_sliderSetValue() by adding following lines at the end right after "e_input.value = n_value;"
var tmpSum = 0;
for(var i = 0; i < A_SLIDERS.length; i++) {
tmpSum += A_SLIDERS.n_value;
}
if(tmpSum > 100) {
this.f_setValue(n_value - 10);
}
This can surely be implemented more elegant, but it works. ;-)
Greetings.
-Manuel |
|
|
|