[thelist] accessing globla JS array from function

Brian Cummiskey brian at hondaswap.com
Sat Jul 7 22:55:14 CDT 2007

Matt Warden wrote:
> On 7/7/07, Brian Cummiskey <brian at hondaswap.com> wrote:
>> unfortunately, this is giving me "F" and "U"
> Brian, your code is trying to tell you something!

> This is going to be a mess! I strongly suggest you do not go down this
> path (although it unfortunately seems like you have already done some
> work). You are fixing a data problem with application code, and
> JavaScript at that!
You're absolutely right that its a mess.  I inherited this project less 
than a week ago, and this client was supposed to launch this past 
Friday.  The other developer who was working on it gave up and passed 
the buck up a level to me.  On top of the fact that the site is riddled 
with tables, useless spans everywhere, javascript-only menus, and so on, 
the back end is a disaster to boot.

Perhaps i should start over outlining the whole issue.  So, here we go.

We have a DB table in our system which holds style information up to 3 
levels of style per sku (as limited by the 3rd party system).  This 
table is synced to a 3rd party system every hour, thus, i can't alter 
the table in any way.
The 2 i'm working with are sizes and colors.  The 5 fields that matter 
to me for this part are:


code holds the codeid and desc holds the text description 
(sm => Small  or FU=> Fuschia)
L1 is color
L2 is size

sku is joined to the inventory table to relate to the product.

The way our system is set up (and i have no control over) is that the 
items that display are "fake".
ie, sku 123456
sku 123456 is NOT an orderable item, as it has no style associated with 
it (you can't order a pair of pants without a size and a color) and does 
NOT exist in our inventory table.

On the product display page, the REAL sku needs to be generated by the 
style options and then adds that valid orderable sku to the cart, along 
the likes of SKU COLORCODE SIZECODE;  or,  "123456 FU SM" as we do a 
split on spaces.

In order to generate this sku, I need to provide the user select options 
to create the desired product sku and add that sku to their cart, but 
ONLY if it exists.

The problem is that not all colors are available in all sizes.
Thus, I need to dynamically allow for generated dropdowns for the size 
based on the color choice so that people can't order invalid sku's.

A good example of what i'm trying to pull off can be found at the old 
navy store
on this product, the 29" waits is only available in 30" length

on the main product page, you can see the sku:  #313127

if you select an orderable size and length, then add it to your bag, and 
then view your bag, you will see it has rendered the correct orderable sku:
(I chose 36x28)

This is exactly what i need to mimic, but instead of waist and inseam, i 
have colors and sizes, thus they don't order nicely for display 
purposes.  I am firstly concerned with creating a valid sku, and making 
it look pretty/in order second.

Now, on top of all this, They have swatches for the colors, and when 
clicking the swatch, the product image changes to the selected color, 
and the drop down gets pre-selected to that choice for the color.  This 
is all built already.
The only issue i'm running into is that when a swath is clicked, i no 
longer have the onchange method attached to the select box, as JS alters 
the selectedIndex of the options.  So i need to add a secondary function 
in there for when the swatch is clicked to also call the size options 

90% of the site requires javascript to function in the first place (hey, 
i didn't code it... the client did) so i'm not too worried about relying 
on it (as they probably won't even get to this point in the store 
without it on anyway).  I'm well versed  in unobtrusive methods, but at 
this point, it's really not worth my time and i just need to get it 
done.... even if it only supports 90% of users.  (i can see a thread 
forming about this already.... but at the end of the day, the client is 
already past their setup fees, and I'm pretty much working for free at 
this point)  The target audience for the store probably don't even know 
how to turn it off anyway.

So, with all that said.....

I have no idea what i'm doing :)

I've attacked this 3 different ways already, and none are working to the 
desired effect.

More information about the thelist mailing list