views:

45

answers:

1

I'm using a slider so that users can select their place in a range from 1-10 (or a similar range)

I know that i can specify the values/steps for the slider but can i have those values correspond to another?

i.e. 
1 = id3040 
2 = id0290
3 = id3782

So if they select '3' on the slider, I can get that corresponding value?

I have a survey and this will be used multiple times on the page, with the values being pulled from the db

A: 

Well, you can use an array to store the values you need, like this:

var values = ['id3040', 'id0290', 'id3782'];

Then define an event when initializing the slider to access the values stored in the array

stop: function(event, ui){
    console.log(values[ui.value]);
}

See: http://jsfiddle.net/wL7Ww/

Yi Jiang