3

I want to do something: http://astro.unl.edu/naap/hr/animations/hrExplorer.html

This example is in Flash but I'm doing mine in JQuery.

See my code: http://jsfiddle.net/NYZrz/9/

I'm having problem with the Slider "step" . In first link the value start in 1.0, the min=0.00010 and the max: 1000000

I want to horizontal Slider to look like:

0.00010 | 0.00012 | 0.00014 | 0.00017 | .... | 0.0090 | 0.011 | .... | 0.10 | 0.12 | 0.14 | ... | 1.0 | 1.2 | 1.4 | ... | 9.0 | 11 | 13 | 16 | .... | 5400 | ... | 1000000

But my code does not do this.

Can you help me??

Thanks....

David
  • 171
  • 2
  • 6
  • 18

1 Answers1

1

Use num.toPrecision(2) instead of toFixed to always get 2 significant digits. I updated your fiddle.

EDIT. To make numbers below 10, quite simply:

var _num = (num < 10) ? num.toPrecision(2) : Math.round(num)

(num < 10 instead of num < 1)

I updated your fiddle again.

cambraca
  • 27,014
  • 16
  • 68
  • 99
  • So now I did what you said but still the first value as an integer. It should be like this example: 1.0 | 1.2 | 1.4 | ... | 9.0 | 11 | .... | 1000000. When I reduce the value of the slider is appearing right now ...0.00010 Thanks.. – David Jan 25 '12 at 18:04
  • I did what you said and is working properly. Another question. See my code: http://jsfiddle.net/NxNXJ/5/ The star should be the same size as the sun at this link: http://astro.unl.edu/naap/hr/animations/hrExplorer.html, but this is not happening. I'm not able to solve this. Thanks, – David Jan 26 '12 at 11:26
  • It's best if you ask a separate question about this. It seems some math is involved... – cambraca Jan 26 '12 at 15:09
  • Remember to always accept the correct answer (using the "check" icon on the left) – cambraca Jan 26 '12 at 15:33