A small but persistent issue with the default Cartweaver product selection script shows up when a product has more than one set of options. For example, you have skus with a range of colors and a range of sizes.

I finally took a few minutes to create a fix, which was actually quite simple to implement. And in the interest of keeping it non-denominational, I didn't even use jQuery... just plain 'ol javascript that can easily be added to any existing CW site.

Link: Sample Product with Default Behavior

Here is an example of a product with a choice of both color and size. The issue occurs when you choose from the first box - in this case, color, and then , either with or without making a selection from the second list , you change the first box back to the default option of "Choose Color...".

Try it and see what happens to the price - it goes blank. And the size list below gets truncated, saying "No Options Available" rather than returning to the original state, showing all sizes, when the page loads.

To fix this, I decided to go the simple route and simply remove the default option from the list once a selection has been made.

Link: Sample Product with Improved Behavior

Here's the added code. Cartweaver makes it easy to modify the script - there is already a function in 'dropdowns.js' called "cwSetDependentList()" that gets called when the selection lists are changed.

I simply added these lines just below the initial block of 'var xx = yy' stuff at the top of the cwSetDependentList function.

view plain print about
1var ii;
4if(objCurrentList.options[ii].value == 0)

This simply loops through the options in the current <select> list, and deletes the one with a value of "0", which is the value given in the default code to the "Select Color..." link.

As far as I can tell from this simple test, it works just fine. As always, feedback is appreciated.