[noob]jQuery Slider string help
Hi all,
Am trying to get this chunk of code to work at the moment. The code replaces the normal numeric values on the slider with strings instead. Now, the strings appear fine when moving the slider but I am unable to fathom out how to get the initial result displayed correctly. At the moment I can get it to display the numeric representation of the string value only...
I've left in the commented out sections of my pathetic attempts to get this to work..
- <script>
var increments = {
0: "zero",
1: "one",
2: "two",
3: "three",
4: "four"
};
$(function() {
$( "#slider-range" ).slider({
//range: true,
min: 0,
max: 4,
//values: [ 0, 4 ],
value: 1,
slide: function( event, ui ) {
//$( "#amount" ).val("from £" + ui.values[ 0 ] + " to £" + ui.values[ 1 ]);
$("#amount").val(increments[ui.value]);
}
});
//$( "#amount" ).val( "from £" + $( "#slider-range" ).slider( "values", 0 ) + " to £" + $( "#slider-range" ).slider( "values", 1 ) );
$( "#amount" ).val(increments[( "#slider-range" ).slider( "value")]);
//$("#amount").val(range[$("#slider-range").slider("value")]);
});
//getter
var discountrange = $( ".selector" ).slider( "option", "value" );
</script>
Now, as a slightly different experiment, you can tell I've also been trying to get this working as a 'range' slider. The goal would be to have a range selected that picks out both strings eg "one - three" etc
Thanks in advance
Chris