Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need slider that can increment exponentially (not using range)

At the moment I am using jQuery UI's slider to allow people to select a donation amount. The problem is, the slider is to small and needs to compensate for the minimum of $1 and the maximum of $10,000. The proposed solution is to use a small increment, maybe $1 or $2, for values between $1 - $1000, and then from there, raising the increment exponentially all the way to $10,000, but I can't find a plugin capable of this.

So right now I have the increment at $1 and as you probably guessed, its nearly possible to select a specific money amount.

Any help would be great!

like image 275
John Avatar asked Nov 05 '22 07:11

John


2 Answers

A slider hardly strikes me as the right tool for that job.

But if you insist, you could increase the slider step size (say, 10 possible positions) and for each step lookup the amount it corresponds to.

Example:

  • 1 -> 1$
  • 2 -> 2$
  • 3 -> 5$
  • 4 -> 10$
  • 5 -> 50$
  • 6 -> 200$
  • 7 -> 1k$
  • 8 -> 5k$
  • 9 -> 10k$
  • 10 -> 20k$
like image 130
biasedbit Avatar answered Nov 09 '22 02:11

biasedbit


To add to @brunodecarvalho's answer, make a JSlider with tick marks but no labels, couple it with a JLabel or a JTextField so that when the slider's value is changed, the appropriately mapped value appears in the JLabel or JTextField.

If you're using a JTextField, trust the value in the JTextField as the user's actual donation amount (so that he can edit it and pick a value that's not on the slider), and update the slider to an appropriately close tick mark when the JTextField changes.

like image 29
Ken Bloom Avatar answered Nov 09 '22 02:11

Ken Bloom