Working fiddle of the what I am trying to do : http://ift.tt/1JreGgJ
The category and products drop down are working using a switch statement.
What I want to do is :
Add a new case called Wattage. The user selects a product and a respective wattage for that product is displayed everytime.
below is my attempt at pseudo code
// define wattage array
function configureDropDownLists(category, products) {
var refrigerators = new Array('Artic King AEB', 'Artic King ATMA', 'Avanti Compact', 'Bosch SS');
var dishWasher = new Array('Bosch - SHXUC', 'Asko DS', 'Blomberg', 'Amana');
var wattage = newArray {
Artic King AEB: 270,
Artic King ATMA: 311,
Avanti Compact: 340,
Bosch SS: 214,
Bosch - SHXUC: 200,
Asko DS: 187,
Blomberg: 236,
Amana: 150
};
);
switch (category.value) {
case 'refrigerators':
products.options.length = 0;
for (i = 0; i < refrigerators.length; i++) {
createOption(products, refrigerators[i], refrigerators[i]);
}
break;
case 'dishWasher':
products.options.length = 0;
for (i = 0; i < dishWasher.length; i++) {
createOption(products, dishWasher[i], dishWasher[i]);
}
break;
case 'wattage':
// on change run through the dishWasher array to match wattage
// products names matches then display the wattage
// or
// if(products.options == wattage.options)
// display wattage
}
break;
default: products.options.length = 0;
break;
}
}
Also how do I keep my drop downs selected (once the user has completed selection of the product.)
Thanks
Aucun commentaire :
Enregistrer un commentaire