X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Javascript Validation for Product Options (https://forum.x-cart.com/showthread.php?t=34831)

carpeperdiem 10-24-2007 06:51 AM

Re: Javascript Validation for Product Options
 
PS - make sure your js validation doesn't have any extra whitespace. Here is an example again...

Code:

if (document.getElementById('po444').selectedIndex == 0)
{ alert('Please select...'); return false;
}
if (document.getElementById('po445').selectedIndex == 0)
{ alert('Please select...'); return false;
}
if (document.getElementById('po447').selectedIndex == 0)
{ alert('Please select...'); return false;
}
else return true;


TL408 10-24-2007 01:39 PM

Re: Javascript Validation for Product Options
 
Thank you, carpeperdiem!

boomobile 03-11-2008 08:50 AM

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...

SMS 03-26-2008 07:53 AM

Re: Javascript Validation for Product Options
 
Anyone notice in 4.1.9 that the "Select" text part does not default to the top of the dropdown on the product page. Can't seem to figure out, by default it goes to my first option.

I have seen most of the posts referencing the latest version but no fixes for what might be a unusual issue.

Thanks,

Bruce

gotpump 07-11-2010 02:01 PM

Re: Javascript Validation for Product Options
 
Anyone know if this works in 4.3 or how to get it working?


All times are GMT -8. The time now is 02:26 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.