function setAddTo(theForm, addToType) { theForm.addTo.value = addToType; theForm.submit(); } // This is an example of sending product data from the server // to the client, then formatting the variants on the client-side // based on certain criteria. function cbFormatter(list, attribute, opt) { // Get the price for this variant.. If this is the primary list, get all related // variants from the group and get their prices as well so we can build a range. var pvds = list.productVariantDropdownSupport; // Get all of the product variants for this attribute var variantGroup = attribute.getVariant().getProductVariantGroup(); var groupVariants = variantGroup.getAllVariants(); // Are all of the prices the same within the group? var lowGroupPrice = 999999.00; var highGroupPrice = -1.00; for (var idx = 0; idx < groupVariants.length; idx++) { lowGroupPrice = groupVariants[idx].numericPrice < lowGroupPrice ? groupVariants[idx].numericPrice : lowGroupPrice; highGroupPrice = groupVariants[idx].numericPrice > highGroupPrice ? groupVariants[idx].numericPrice : highGroupPrice; } // Are all of the prices the same within the variant? var variants = variantGroup.getVariantsMatching(attribute.name, attribute.value); var lowVariantPrice = 999999.00; var highVariantPrice = -1.00; var lowVariantDisplay = variants[0].displayPrice; var highVariantDisplay = variants[0].displayPrice; for (var idx = 0; idx < variants.length; idx++) { // Display really needs to be done before the re-assignment... lowVariantDisplay = variants[idx].numericPrice < lowVariantPrice ? variants[idx].displayPrice : lowVariantDisplay; lowVariantPrice = variants[idx].numericPrice < lowVariantPrice ? variants[idx].numericPrice : lowVariantPrice; highVariantDisplay = variants[idx].numericPrice > highVariantPrice ? variants[idx].displayPrice : highVariantDisplay; highVariantPrice = variants[idx].numericPrice > highVariantPrice ? variants[idx].numericPrice : highVariantPrice; } if (lowGroupPrice != highGroupPrice) { // Primary list should display a range if (pvds.isPrimary) if (lowVariantPrice != highVariantPrice) opt.text = opt.text + " " + lowVariantDisplay + " - " + highVariantDisplay; else opt.text = opt.text + " " + attribute.getVariant().displayPrice; else // Secondary lists should show exact price opt.text = opt.text + " " + attribute.getVariant().displayPrice; } return opt; } /* This function is called from variant_dropdown.js script to handle Select Color drowndown onChange event */ function updateInvQty(qty){ try { document.getElementById("invQty").innerHTML = qty; } catch (e) { // There is no label on this page. } } function updateProductImageColor(productId, colorName) { loadSwatch(productId); setColorTextValue(colorName, productId); } function changeColor(productId, colorDropdownList) { for (i = 0; i < colorDropdownList.length; i++) { if (colorDropdownList.options[i].selected) { if (colorDropdownList.options[i].text != "Select One") { setColorTextValue(colorDropdownList.options[i].value, productId); setSelectedSwatch(colorDropdownList.options[i].value, productId); } else { setColorTextValue("", productId); // reset selected swatch for (i = 0; i < arrColorsTemp.length; i++) { document.getElementById("sw_" + arrColorsTemp[i] + productId).className = "sw-off"; } } } } } var arrColorsTemp = new Array(); // hold arrColors value when color combox selected function loadSwatch(productId) { var html = ""; var imageUrl = ""; html += "
"; for (i = 0; i < arrColors.length; i++) { html += "