can some one help me how to code this. I am trying to do this:
1) The user selects a Category based on that selection products gets populated. (working)
2) The user selects the products and I want to display its wattage which is stored using LocalStorage.
3) The user can select any products and on change the wattage should change accordingly.
4) Default wattage is 0.
5) Also I dont know how to describe this problem : When I click on any of the four buttons my drop down selection resets.
This is my link to the working code: http://ift.tt/1KHhCGQ
below is my attempt at writing the code.
//Define wattage array
//get wattage array
//Check for which product is selected and accordingly display the Wattage.
//This has to happen onChange of the products dropdown.
/*
// define wattage array
var wattageArray = localStorage {
Artic King AEB: 270,
Artic King ATMA: 311,
Avanti Compact:340,
Bosch SS: 214,
Bosch - SHXUC: 200,
Asko DS: 187,
Blomberg: 236,
Amana: 150
};
// call wattage array inside init
window.onload = init;
function init() {
//options.onchange = displayWattage;
var wattageArray = getWattageArray();
for (var i = 0; i < wattageArray.length; i++) {
var key = wattageArray[i];
var value = wattageArray[i];
}
}
function getWattageArray() {
var wattageArray = localStorage.getItem("wattageArray");
for (options.selectedIndex == wattageArray) {
var value = parseInt(localStorage.getItem[i]));
document.getElementById("wattage").innerHTML = value;
}
}
//localStorage.setItem("Artic King AEB",270);
//localStorage.setItem("Artic King ATMA",311);
//localStorage.setItem("Avanti Compact",340);
//localStorage.setItem("Bosch SS",214);
//localStorage.setItem("Bosch - SHXUC",200);
//localStorage.setItem("Asko DS",187);
//localStorage.setItem("Blomberg",236);
//localStorage.setItem("Amana",150);
//var sticky = parseInt(localStorage.getItem("Blomberg"));
//alert(sticky);
Aucun commentaire:
Enregistrer un commentaire