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

Javascript Error - Help Needed

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-02-2006, 10:01 AM
  dalmuti's Avatar 
dalmuti dalmuti is offline
 

eXpert
  
Join Date: Oct 2004
Location: Kansas
Posts: 343
 

Default Javascript Error - Help Needed

Hello,

We are getting a javascript error if a product has options (no options - no error). I've made changes to the product.tpl template but cannot seem to determine how to fix this error:

Line: 809
Char: 2
Error: 'avail' is undefined

That error relates to the line below.

if((mq > 0 && avail > mq) || is_unlimit == 'Y')
avail = mq;

Has anyone seen this error before or give me a pointer where to look?

Thanks,

Louise
__________________
Louise

Studio 57 Designs - X-Cart Customization
Providing X-Cart Services since 2004
Hottest Blog Directory - Submit Your Blog for a Free Listing
Reply With Quote
  #2  
Old 02-03-2006, 09:25 AM
  dalmuti's Avatar 
dalmuti dalmuti is offline
 

eXpert
  
Join Date: Oct 2004
Location: Kansas
Posts: 343
 

Default

Anyone have any idea about this error? Thanks
__________________
Louise

Studio 57 Designs - X-Cart Customization
Providing X-Cart Services since 2004
Hottest Blog Directory - Submit Your Blog for a Free Listing
Reply With Quote
  #3  
Old 02-03-2006, 09:34 AM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,052
 

Default

Why not paste your product.tpl here, maybe someone will be able to suss it out from the whole code?
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #4  
Old 02-03-2006, 09:38 AM
  dalmuti's Avatar 
dalmuti dalmuti is offline
 

eXpert
  
Join Date: Oct 2004
Location: Kansas
Posts: 343
 

Default

Here is my product.tpl file:

Code:
{* $Id: product.tpl,v 1.96.2.24 2005/11/07 09:17:46 svowl Exp $ *} {if $active_modules.Special_Offers} {include file="modules/Special_Offers/customer/product_offers_short_list.tpl" product=$product} {/if} {include file="form_validation_js.tpl"} {if $product.product_type eq "C" && $active_modules.Product_Configurator} {include file="modules/Product_Configurator/pconf_customer_product.tpl"} {else} {capture name=dialog} <TABLE border="0" width="100%"> <FORM name="orderform" method="post" action="cart.php?mode=add" onsubmit="javascript: return FormValidation();"> <INPUT type="hidden" name="addproductid" value="{$product.productid}"> <INPUT type="hidden" name="slot" value="{$smarty.get.slot}"> <INPUT type="hidden" name="mode" value="add"> <input type="hidden" name="amount" value="1"> <INPUT type="hidden" name="addproductid" value="{$product.productid}"> <INPUT type="hidden" name="slot" value="{$smarty.get.slot}"> <INPUT type="hidden" name="mode" value="add"> <INPUT type="hidden" name="amount" value="1"> <TR> <TD valign="top" align="left" rowspan="2"> <table border="0" width="230" style="border-collapse: collapse"> <tr> <td valign="top" align="center">{include file="customer/main/product_image_detail.tpl"}</td> </tr> <tr> <td valign="top"></td> </tr> <tr> <td valign="top"> <table border="0" width="100%" cellspacing="7" style="border-collapse: collapse"> <tr>{if $config.Appearance.show_in_stock eq "Y" and $config.General.unlimited_products ne "Y" and $product.distribution eq ""} <TR><TD width="100" valign="top" height="20" align="right">{$lng.lbl_quantity}</TD> <TD nowrap height="20" valign="top" align="left"><SPAN id="product_avail_txt">{if $product.avail gt 0}{$product.avail}</SPAN>{else}{$lng.txt_no}{/if} {$lng.txt_items_available}</TD></TR> {/if} {if $active_modules.Extra_Fields ne ""} <tr> <td colspan="2"> {include file="modules/Extra_Fields/product.tpl"} </td> </tr> {/if} {if $active_modules.Feature_Comparison ne ""} {include file="modules/Feature_Comparison/product.tpl"} {/if} {if $active_modules.Subscriptions ne "" and $subscription} {include file="modules/Subscriptions/subscription_info.tpl"} {else} <TR><TD class="ProductPriceConverting" valign="top" height="30" align="right" colspan="2"> <table border="0" width="100%" cellpadding="0" style="border-collapse: collapse"> <tr> <td class="ProductPriceConverting" valign="top" width="100" height="30" align="right">{$lng.lbl_price}:</td> <TD valign="top" height="30" align="left"> {if $product.taxed_price ne 0 || $variants ne ''} <FONT class="ProductDetailsTitle"><SPAN id="product_price">{include file="currency.tpl" value=$product.taxed_price}</SPAN></FONT><FONT class="MarketPrice"> <SPAN id="product_alt_price">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product.taxed_price}</SPAN></FONT> {if $product.taxes} {include file="customer/main/taxed_price.tpl" taxes=$product.taxes}{/if} {else} <INPUT type="text" size="7" name="price"> {/if} </TD> </tr> </table> </TD> </TR> {/if} </tr> <TR>{if $active_modules.Product_Options ne ""} { include file="modules/Product_Options/customer_options.tpl"} {/if} {* <TR><TD height="30" valign="top" align="right" colspan="2"> <p align="left">{if $config.General.unlimited_products eq "N" and ($product.avail le 0 or $product.avail lt $product.min_amount) and $variants eq ''} <SCRIPT type="text/javascript" language="JavaScript 1.2"> var min_avail = 1; var avail = 0; var product_avail = 0; </SCRIPT> {$lng.txt_out_of_stock} {else} {if $config.General.unlimited_products eq "Y"} {math equation="x+1" assign="mq" x=$config.Appearance.max_select_quantity} {else} {math equation="x/y" x=$config.Appearance.max_select_quantity y=$product.min_amount assign="tmp"} {if $tmp<2} {assign var="minamount" value=$product.min_amount} {else} {assign var="minamount" value=1} {/if} {math equation="min(maxquantity+minamount, productquantity+1)" assign="mq" maxquantity=$config.Appearance.max_select_quantity minamount=$minamount productquantity=$product.avail} {/if} {if $product.distribution eq "" and !($active_modules.Subscriptions ne "" and $subscription)} {if $product.min_amount le 1} {assign var="start_quantity" value=1} {else} {assign var="start_quantity" value=$product.min_amount} {/if} <SCRIPT type="text/javascript" language="JavaScript 1.2"> var min_avail = {$start_quantity|default:1}; var avail = {$mq|default:1}-1; var product_avail = {$product.avail|default:"0"}; </SCRIPT> {/if} {/if}</TD> </TR> *} <TR><TD height="30" valign="top" align="right" colspan="2"> <table border="0" width="100%" style="border-collapse: collapse"> <tr> <td width="60"></td> <td> <INPUT type="hidden" name="mode" value="add"> <p align="center">{if $variants eq ''} {include file="customer/main/product_prices.tpl"} {/if} {if $config.General.unlimited_products eq "Y" or ($product.avail gt 0 and $product.avail ge $product.min_amount)} {if $js_enabled} {* *} {if $smarty.get.pconf ne ""} <INPUT type="hidden" name="slot" value="{$smarty.get.slot}"> <INPUT type="hidden" name="addproductid" value="{$product.productid}"> {include file="buttons/button.tpl" button_title=$lng.lbl_pconf_add_to_configuration style="button" href="javascript:if (FormValidation()) `$ldelim`document.orderform.productid.value='`$smarty.get.pconf`';document.orderform.action='pconf.php';document.orderform.submit()`$rdelim`"} {/if} {if $product.forsale ne "B"} {include file="buttons/add_to_cart.tpl" style="button" href="javascript: if(FormValidation()) document.orderform.submit();"} {if $login ne "" and $active_modules.Wishlist ne ""} {include file="customer/add2wl.tpl"} {/if} {else} {$lng.txt_pconf_product_is_bundled} {/if} {else} {include file="submit_wo_js.tpl" value=$lng.lbl_add_to_cart} {/if} {/if} {if $active_modules.Feature_Comparison ne ""} {include file="modules/Feature_Comparison/product_buttons.tpl"} {/if}</td> <td width="60"></td> </tr> </table> </TD> </TR> </table> </td> </tr> </table> </TD> <TD valign="top" width="10"> </TD> <TD valign="top" width="575"> <SPAN class=> {if $product.fulldescr ne ""}{$product.fulldescr}{else}{$product.descr}{/if} </SPAN> </TD> </TR> <INPUT type="hidden" name="productid" value="{$product.productid}"> <INPUT type="hidden" name="cat" value="{$smarty.get.cat|escape:"html"}"> <INPUT type="hidden" name="page" value="{$smarty.get.page|escape:"html"}"> </FORM> </TABLE> {/capture} {*{include file="dialog.tpl" title=$product.producttitle content=$smarty.capture.dialog extra="width=100%"}*} {include file="customer/main/product_dialog.tpl" title=$product.product content=$smarty.capture.dialog extra="width=100%"} {/if} {*{include file="customer/main/send_to_friend.tpl" } {if $active_modules.Detailed_Product_Images ne ""} {include file="modules/Detailed_Product_Images/product_images.tpl" } {/if}*} {if $active_modules.Upselling_Products ne ""} {include file="modules/Upselling_Products/related_products.tpl" } {/if} {if $active_modules.Recommended_Products ne ""} {include file="modules/Recommended_Products/recommends.tpl" } {/if} {if $active_modules.Customer_Reviews ne ""} {include file="modules/Customer_Reviews/vote_reviews.tpl" } {/if} {if $active_modules.Product_Options ne '' && $product_options ne ''} <SCRIPT type="text/javascript" language="JavaScript 1.2"> check_options(); </SCRIPT> {/if}

Thank you for any assistance.

Louise
__________________
Louise

Studio 57 Designs - X-Cart Customization
Providing X-Cart Services since 2004
Hottest Blog Directory - Submit Your Blog for a Free Listing
Reply With Quote
  #5  
Old 02-03-2006, 09:51 AM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,052
 

Default

I don't know if this is your answer, but at line 76 and 100 the variable avail is being defined and your error says that avail isn't defined.

As line 76 and 100 are in a section of code that is commented out you may want to try and put this code back in.

I cannot see avail being defined anywhere else in the code that isn't being take out.
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #6  
Old 02-03-2006, 10:03 AM
  dalmuti's Avatar 
dalmuti dalmuti is offline
 

eXpert
  
Join Date: Oct 2004
Location: Kansas
Posts: 343
 

Default

Thanks Paul, I'll give that a try.

Louise
__________________
Louise

Studio 57 Designs - X-Cart Customization
Providing X-Cart Services since 2004
Hottest Blog Directory - Submit Your Blog for a Free Listing
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 10:59 PM.

   

 
X-Cart forums © 2001-2020