Creating a dynamic two-column iOS spinning wheel with HTML/Javascript

Posted by JSW189 on Stack Overflow See other posts from Stack Overflow or by JSW189
Published on 2012-11-15T16:58:26Z Indexed on 2012/11/15 16:59 UTC
Read the original article Hit count: 203

Filed under:
|

I am trying to create a dynamic two-column spinning wheel for iOS Safari using this HTML/Javascript wheel. However, I am having trouble getting the value of the first column to change the results of the second column.

I have tried using an if statement to get the value of the first variable (var beverage) and add the value of the second column correspondingly. Does anybody know what I am doing wrong/if there is a better approach?

function openBirthDate() {
var beverage = { 1:'Coffee', 2:'Soda' };

//THIS IS WHERE I'M HAVING TROUBLE
var results = SpinningWheel.getSelectedValues();
if (results.values === 1) {
    var company = { 1:'Starbucks', 2:'Dunkin Donuts' }; 
} else {
    var company = { 1:'Coke', 2:'Pepsi' }; 
}

var size = { 1:'Tall', 2:'Grande', 3:'Venti' }; 

SpinningWheel.addSlot(type, '', 1);
SpinningWheel.addSlot(company, '', 1);
SpinningWheel.addSlot(size, '', 1);

SpinningWheel.setCancelAction(cancel);
SpinningWheel.setDoneAction(done);

SpinningWheel.open();
}

function done() {
var results = SpinningWheel.getSelectedValues();
document.getElementById('result').innerHTML = 'values: ' + results.values.join(' ') + '<br />keys: ' + results.keys.join(', ');

}

function cancel() {
    document.getElementById('result').innerHTML = 'cancelled!';
}


window.addEventListener('load', function(){ setTimeout(function(){ window.scrollTo(0,0); }, 100); }, true);

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about mobile-safari