var onItemOptionChange = function(obj) { document.getElementById('itemPrice').innerHTML = getPriceByVariant(obj.options[obj.options.selectedIndex].value); document.getElementById('retailPrice').innerHTML = getRetailPriceByVariant(obj.options[obj.options.selectedIndex].value); if (getAttributeValueByVariant('Weight',obj.options[obj.options.selectedIndex].value)) document.getElementById('attribute_Weight').innerHTML = getAttributeValueByVariant('Weight',obj.options[obj.options.selectedIndex].value); if (getAttributeValueByVariant('Width',obj.options[obj.options.selectedIndex].value)) document.getElementById('attribute_Width').innerHTML = getAttributeValueByVariant('Width',obj.options[obj.options.selectedIndex].value); } var getAttributeValueByVariant = function(attributeName, variantValue) { if (attributeName == 'Weight' && variantValue == '') return '41.50'; if (attributeName == 'Weight' && variantValue == '7\"') return '41.50'; if (attributeName == 'Width' && variantValue == '') return '12mm'; } var getPriceByVariant = function(variantOption) { if (variantOption == '7\"') return '$1,363.35'; if (variantOption == '8\"') return '$1,558.11'; } var getRetailPriceByVariant = function(variantOption) { if (variantOption == '7\"') return '$2,522.20'; if (variantOption == '8\"') return '$2,882.51'; } var addToBasket = function() { if (document.getElementById('itemOptions')) { var obj = document.getElementById('itemOptions').options; document.getElementById('i_variant_option').value = obj[obj.selectedIndex].value; } document.getElementById('i_qty').value = document.getElementById('qty').options[document.getElementById('qty').options.selectedIndex].value; document.getElementById('addForm').submit(); }