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('Width',obj.options[obj.options.selectedIndex].value)) document.getElementById('attribute_Width').innerHTML = getAttributeValueByVariant('Width',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); } var getAttributeValueByVariant = function(attributeName, variantValue) { if (attributeName == 'Width' && variantValue == '') return '7mm'; if (attributeName == 'Weight' && variantValue == '') return '14.30'; if (attributeName == 'Weight' && variantValue == '7\"') return '14.30'; } var getPriceByVariant = function(variantOption) { if (variantOption == '7\"') return '$516.98'; } var getRetailPriceByVariant = function(variantOption) { if (variantOption == '7\"') return '$956.42'; } 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(); }