Quote:
Originally Posted by hrothbeorht
I've tried a buch of different things with the Javascript for two products.
I nearly had it working once but one of the things wrong was that it was opening an alert for the size,
I'd click ok and immediatly another would open with the colour. I thought if there were going to be
two alerts I'd rather have a script that had three alerts:
1- please choose a size and colour (if neither are selected)
2- please choose a size (if only the colour has been chosen)
3- please choose a colour (if only the size has been chosen)
-hroth
|
the reason you get one alert after another is because of your "if" statement...you have 2 "if" statements, but seems what you want is a "if,elseif" statement,
ie:
if (neither selected) alert (both not selected)
elseif (color selected) alert (size not selected)
elseif (size selected) alert (color not selected)
else (submit)
also, if you dont use color-size combo validations, then you can just change the if statement to check if the index is 0 or if the value contains "select" instead of checking against all the sizes and colors