Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

productAddToCartForm causing javascript error on product view page
 
ourmaninparis
Member
 
Avatar
Total Posts:  40
Joined:  2008-03-03
 

Hello,

I’ve been doing really well getting my first real site on-line but now I’m stuck :(

The “add to cart” button on the product view page will not work in Internet Explorer (6 and 7). It works fine in Firefox. It appears to be linked to two javascript problems:

1. On page load the error:

Line: 3171

Error: this object doesn’t support this property of method

2. When clicking the ‘add to cart’ button:

Line: 182

Error: ‘productAddToCartForm’ is null or not an object

-------------------

The second error seems to be related to the file addtocart.phtml.

-------------------

I don’t really have a clue what to do!

The other ‘add to cart’ buttons on the site work fine. So I initially tried copying the ‘add to cart’ code from the view.phtml file to the addtocart.phtml. This activated the button but the wrong quantity of product is added to the cart (always one to many.)

Can anybody help me with this?

If useful, here is an example of a page with an error: http://www.nouveaux-thes.fr/thes-tisanes-moment/the-oolong.html

Regards, Shaun.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ourmaninparis
Member
 
Avatar
Total Posts:  40
Joined:  2008-03-03
 

A little more information on things I’ve been trying.

- I replaced the catalog.xml file with the one from the default theme - this didn’t make any difference.
- I replaced media.phtml with the one from the default theme as mine was using a javascript zoom that I thought may be causing problems. It wasn’t!

I’m really stuck and on such an important page!!!

Regards, Shaun.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ourmaninparis
Member
 
Avatar
Total Posts:  40
Joined:  2008-03-03
 

Another update:

I’ve found that I can replace the code in order to just have the “add to cart” button without the quantity:

Original Code (addtocart.phtml) :

?>

<?php $_product = $this->getProduct() ?>

<?php if($_product->isSaleable()): ?>
<fieldset class="add-to-cart-box">
<legend><?php echo $this->__('Add Items to Cart') ?></legend>
<?php if(!$_product->isGrouped()): ?>
<span class="qty-box"><label for="qty"><?php echo $this->__('Qty') ?>:</label>
<input name="qty" type="text" class="input-text qty” id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>” /></span>
<?php endif; ?>
<button class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('Add to Cart') ?></span></button>
</fieldset>
<?php endif; ?>

New Code (addtocart.phtml):

?>

<?php $_product = $this->getProduct() ?>

<?php if($_product->isSaleable()): ?>
<fieldset class="add-to-cart-box">
<legend><?php echo $this->__('Add Items to Cart') ?></legend>
<?php if(!$_product->isGrouped()): ?><?php endif; ?>
<button class="form-button" onclick="setLocation(’<?php echo $this->getAddToCartUrl($_product) ?>’)"><span><?php echo $this->__('Add to Cart') ?></span></button>
</fieldset>
<?php endif; ?>

--------------------------------

This gives me a temporary fix but it is a real shame not to have the quantity option and could result in less sales.

The other thing is, I’ve just noticed that the ‘add tags’ button doesn’t work on the page either.

I’m not at all technical but I’m wondering if the first error (see original post) is causing the other two errors (Add To Cart button not working, and, Add Tags button not working.)

No doubt I’ll try something else but any suggestions would be appreciated smile

Shaun.

 
Magento Community Magento Community
Magento Community
Magento Community
 
infinitegrace
Jr. Member
 
Total Posts:  8
Joined:  2009-02-22
 

I’m having the same problem. The add to cart button works but returns a javascript error. Tags don’t work at all.

 
Magento Community Magento Community
Magento Community
Magento Community
 
infinitegrace
Jr. Member
 
Total Posts:  8
Joined:  2009-02-22
 

I found this thread: http://www.magentocommerce.com/boards/viewthread/19749/

and it fixed the problem.

I was getting this error when I try to add a tag and clicked on the button:

‘addTagFormJs.validator’ is null or not an object

I found this thread: http://www.magentocommerce.com/boards/viewthread/15273/

and it fixed the problem.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ourmaninparis
Member
 
Avatar
Total Posts:  40
Joined:  2008-03-03
 

Hello,

Thanks for your help.

In the end, the company that provided me with the template supplied a new version, which solved the issue. In fact I just replaced the template files.

I still get some javascript errors in IE6 and 7 but nothing that prevents people from placing orders!! Whew!!!

Regards, Shaun.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nasha
Sr. Member
 
Avatar
Total Posts:  138
Joined:  2009-04-15
 

Hi every one
Check file permission for js folder and the files inside js folder. grin

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top