View Single Post
  #3  
Old 08-08-2007, 12:54 PM
  hrothbeorht's Avatar 
hrothbeorht hrothbeorht is offline
 

Senior Member
  
Join Date: May 2007
Posts: 156
 

Default Re: variations javascript help

thanks inebriate.. I've tried what I can of your suggestions. I have not been able to try it fully becaue I'm not a "JavaScript'r"
(I'm much better at actionscript)

I'll expand on what has been modified. I think I might have left out some important info (sorry)
this is from the post:
http://forum.x-cart.com/showpost.php?p=179500&postcount=18
modifying customer_options.tpl
I replaced:
Code:
{foreach from=$v.options item=o} <option value="{$o.optionid}"{if $o.selected eq 'Y'} selected="selected"{/if}>{$o.option_name}{if $v.is_modifier eq 'Y' && $o.price_modifier ne 0} ({if $o.modifier_type ne '%'}{include file="currency.tpl" value=$o.price_modifier display_sign=1 plain_text_message=1}{else}{$o.price_modifier}%{/if}){/if}</option> {/foreach}
with:
Code:
{if $product.productid ne '9' && $product.productid ne '3' } <option>Select {$v.classtext|default:$v.class}{if $o.selected eq 'Y'} selected="selected"{/if}</option> {/if} {foreach from=$v.options item=o} <option value="{$o.optionid}">{$o.option_name}{if $v.is_modifier eq 'Y' && $o.price_modifier ne 0} ({if $o.modifier_type ne '%'}{include file="currency.tpl" value=$o.price_modifier display_sign=1 plain_text_message=1}{else}{$o.price_modifier}%{/if}){/if}</option> {/foreach}

I wish I knew how to take your advice regarding:
Quote:
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

I don't know how check for what shows as the default value of the drop down menus. When I create the variations, I add only XL, L, M and small
for men_size and black, offwhite for colour_001.

It worked perfectly with one drop down.. I've tried about 50 variation in as many ways as I can to get it to work with two. I really appreciate the help but sadly I just don't get it yet

my latest rendition (still wrong) looks like this:
Code:
var value = product_option_value("men_size"); var value2 = product_option_value("colour_001"); if ((value !== 'XL' && value !== 'L' && value !== 'M' && value !== 'S') && (value2 !== 'black' && value2 !== 'offwhite')){ alert ("please choose a size and colour"); return false; } elseif (value !== 'XL' && value !== 'L' && value !== 'M' && value !== 'S'){ alert ("please choose a size"); return false; } else (value2 !== 'black' && value2 !== 'offwhite'){ alert ("please choose a colour"); return false; }

I changed off-white to offwhite because I thought it might cause a problem.
I tried using elseif and I've tried removing the "return false" in a few places.
I've tried an elseif where you see the else. ..

still trying.. still experimenting.. but still in need of help~!

when I view the source of the page I see this where the drop down menus are:
Code:
<tr> <td valign="middle" height="25">size</td> <td valign="middle"> <select id="po462" name="product_options[462]" onchange="javascript: check_options();"> <option>Select size</option> <option value="4187">S</option> <option value="4186">M</option> <option value="4185">L</option> <option value="4184">XL</option> </select> </td> </tr> <tr> <td valign="middle" height="25">colour</td> <td valign="middle"> <select id="po464" name="product_options[464]" onchange="javascript: check_options();"> <option>Select colour</option> <option value="4190">black</option> <option value="4191">offwhite</option> </select> </td> </tr>
__________________
x-cart- 4.1.10
www.boutiquefinn.ca
Reply With Quote