no9
no9

Reputation: 6544

Magento duplicate element ids

I am validating my store in http://validator.w3.org/ and i have some errors.

Looks like that products from feature slider and new products listing on the homepage have identical ids.

Here is an example of the error:

Line 601, Column 93: ID "product-price-16" already defined

<span class="regular-price" id="product-price-16">

An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).

Line 288, Column 93: ID "product-price-16" first defined here

<span class="regular-price" id="product-price-16">`

Is it possible to define IDs of products from feature slider with an prefix?

Thanks!

Upvotes: 0

Views: 863

Answers (1)

benmarks
benmarks

Reputation: 23205

Product price display is updated by JavaScript using these IDs, and causing a JavaScript error can result in broken JavaScript form handling, namely, add to cart. The template which is rendering these is used in a number of places. You will want to set a different template for the price in the feature slider rather than edit the catalog/product/price.phtml template.

Upvotes: 1

Related Questions