Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Javascript Validation for Product Options

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 10-24-2007, 06:51 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default 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;
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #12  
Old 10-24-2007, 01:39 PM
 
TL408 TL408 is offline
 

X-Adept
  
Join Date: Jan 2005
Posts: 549
 

Default Re: Javascript Validation for Product Options

Thank you, carpeperdiem!
__________________
Win2003 IIS6, PHP 5.2.3, MySQL 5.0.45 and X-Cart 4.1.9
Reply With Quote
  #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
  #14  
Old 03-26-2008, 07:53 AM
 
SMS SMS is offline
 

Newbie
  
Join Date: Aug 2006
Posts: 9
 

Default 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
__________________
X-Cart version 4.0.18
X-Cart version 4.1.9
Reply With Quote
  #15  
Old 07-11-2010, 02:01 PM
 
gotpump gotpump is offline
 

eXpert
  
Join Date: Aug 2008
Posts: 272
 

Default Re: Javascript Validation for Product Options

Anyone know if this works in 4.3 or how to get it working?
__________________
X-Cart DB Version: 5
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:07 AM.

   

 
X-Cart forums © 2001-2020