Search code examples
cordovajquery-mobilemobiscroll

How to change mobiscroll script output format?


I am trying to use mobiscroll for height selection so I have two wheels one with feet & other inches but the output in the text box after selection is displayed with a space in the numbers instead I want a dot in it how can I do that? Below is my code which I am using presently..

var hei=[ { 'Feet': { 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9' }, 'Inches': { 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9' , 10: '10', 11: '11', 12: '12' } } ]
$('#hei').scroller({
        theme: 'default',
        display: 'mixed',
        mode: 'scroller',
        wheels: hei,
        height: 40
    });

And the Html is

<input type="text" name="textinput" id="hei" value="" style="width:50%"  />

Solution

  • Use the formatResult and parseValue

    formatResult: function(data){
                return data[0] + "." + data[1];            
            },
            parseValue: function(valueText)  {
                if (valueText != "") {        
                    return valueText.split(".");
                } else{
                    return [1,1];
                }
            }
    

    For more info go to Mobiscroll documentation. Also see this jsFiddle.