$(function(){
//note: keys are the 1/2 and values are the 1-3/3-4
//in this example we're using the header text to display the values instead of the keys
$('#i').scroller({
wheels : [{
'' : {
'1' : '1 - 3',
'2' : '3 - 4'
}
}],
width : 160,
theme: 'ios',
display: 'inline',
mode: 'scroller',
//mode : 'clickpick',
// theme: 'default',
headerText: function(value){
if (value == '1'){
return '1 - 3';
} else if (value == '2'){
return '3 - 4';
}
}
});
//this example demonstrates the usage of the onSelect and the parseValue
$('#i2').scroller({
wheels : [{
'' : {
'1 - 3' : '1 - 3',
'3 - 4' : '3 - 4'
}
}],
width : 160,
theme: 'ios',
display: 'inline',
mode: 'scroller',
//mode : 'clickpick',
// theme: 'default',
onSelect: function(valueText,inst){
//the onSelect event takes care of setting the inputs value (you could use a variable for this)
if (valueText == '1 - 3'){
$('#i2').val('1');
} else if (valueText == '3 - 4'){
$('#i2').val('2');
}
},
parseValue: function(valueText){
//we need to use the parseValue function in order to parse the 1/2 to the right element
if (valueText == '1'){
//if value from input = 1 return the first element
return ['1 - 3']; //note: we need to retrun an array, where each element is corresponding to a wheel
} else if (valueText == '2'){
//return the second element
return ['3 - 4'];
} else {
//need a default if the input is blank
return ['1 - 3'];
}
}
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.