View Single Post
  #13  
Old 03-11-2008, 08:50 AM
  boomobile's Avatar 
boomobile boomobile is offline
 

eXpert
  
Join Date: Oct 2007
Posts: 306
 

Default Re: Javascript Validation for Product Options

Quote:
Originally Posted by carpeperdiem
For 4.1.x, try this:

[edited] File: /skin1/modules/Product_Options/customer_options.tpl

FIND

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}

REPLACE WITH:

Code:
<option>Please Select Your {$v.classtext|default:$v.class}...{if $o.selected eq 'Y'} selected="selected"{/if}</option> {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}

THEN -- in the product options javascript, use something like this:

Code:
if (document.getElementById('po17').selectedIndex == 0) { alert('Please select...'); return false; } if (document.getElementById('po18').selectedIndex == 0) { alert('Please select...'); return false; } else return true;

and of course, change the 'po' in the js to the actual product option number.


Okay, so my tpl has been altered already, so I'm not sure where to place this...
I have:

{foreach from=$v.options item=o}
<TR>
<TD>{if $o.avail ne 'Y'}<FONT color="red">{/if}{$o.option_name}{if $o.avail ne 'Y'}</FONT>{/if}</TD>
{if $v.is_modifier eq 'Y' && $o.price_modifier ne 0}
<TD>{$o.price_modifier}</TD>
<TD>{if $o.modifier_type|default:"$" eq '$'}{$config.General.currency_symbol}{else}%{/if}</TD>
{/if}
</TR>
{foreachelse}

>>>this changes the font color when an item is on sale...
>>>and this:

{foreach from=$v.options item=o}
<OPTION value='{$o.optionid}'>{$o.option_name}</OPTION>
{/foreach}

>>>which I have no idea what this does...
__________________
X Cart Ver: 4.0.14
MySQL4 4.1.22
phpMyAdmin 2.6.0
Pearl 5.6.0
PHP 5.2.1
Python 2.2.2
Server: Apache/2.0.52 (Red Hat)
OS: Linux
www.cleanlinesurf.com
1. Customer Rewards Points
2. One Page Checkout (altercart)
3. Free shipping orders over $50 as Real Time Shipping
4. Gift Certificates
-----------------------------------------------
Graphic Design | Boomobile Design, LLC
www.boomobile.com
Reply With Quote