View Single Post
  #1  
Old 08-08-2007, 08:34 AM
  hrothbeorht's Avatar 
hrothbeorht hrothbeorht is offline
 

Senior Member
  
Join Date: May 2007
Posts: 156
 

Default variations javascript help

Hi all,

I've got some product variations happening and I've added the mod that adds the "select <option>" into the
drop-down menu of the product variations. (works great!)
I started with one variation, added the javascript in the product options page and all was well.
Now that I have two variations, I need a bit of help getting the right javascript happening.
Here is what I had for one variation that worked:
Code:
var value = product_option_value("men_size"); if (value !== 'XL' && value !== 'L' && value !== 'M' && value !== 'S') { alert("Please select a size"); return false; }
Here is what I have for two variations(does not work):
Code:
var value = product_option_value("men_size"); if (value !== 'XL' && value !== 'L' && value !== 'M' && value !== 'S') { alert("Please select a size"); } var value2 = product_option_value("colour_001"); if (value !== 'black' && value !== 'off-white') { alert("Please select a colour"); return false; }

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
__________________
x-cart- 4.1.10
www.boutiquefinn.ca
Reply With Quote