# Driving Sliders Through Numeric Calculations

By
Mike Adamski

I'm wondering if someone can help me get started on something like this:

I'm looking to setup a system where a learner would input some numbers, which would lead to a calculation, which would then drive a slider interaction.

So for instance, using baseball as an example:

Student enters Hits (150) and At-Bats (550)

Software calculates the batting average as .273 (hits/at-bats)

Then, that .273 number drives a slider which might look something like this:

1-5 scale slider

1: Bad player

2: Below average player

3: Average player

4: Above average player (where .272 would set the slider)

5: Excellent player

Thanks for taking a look!

## 2 Replies

Adjust variable Average = variable Hits when numeric entry box AtBats loses focus

Adjust variable Average divide variable AtBatswhen numeric entry box AtBats loses focus

Then if the spacing between the five options is linear (equally spaced), tie the slider to Average, and it will move when Average changes. Fiddle with the start, stop, and steps until you get what you want.

If they aren't equally spaced, tie the slider to Slider1 and translate Average:

Adjust variable Slider1 = value 1 when numeric entry box AtBats loses focus if Average is between 0 and .150

Adjust variable Slider1 = value 2 when numeric entry box AtBats loses focus if Average is between .151 and .190

Adjust variable Slider1 = value 3 when numeric entry box AtBats loses focus if Average is between .191 and .250

Actually, if you want to show the averages, I forgot that SL keeps only 2 significant digits after the decimal. So the math has to be done in javascript, and the result passed to SL in a text variable.

I'm attaching a version that works.

Baseball.story