I have a webpage that shows one item for sale with a add to cart button. The page uses a lot of javascript so the user can customize the element. I now need to change the page to show multiple similar elements on one page, each additional element is also configured by the user in the same way. Javascript heavily uses an identifier in the markup to find and manipulate elements to provide custom element customization.
My first thought is to allow html markup to be repeated for each element, while also allowing identifiers to repeat, but adding an extra div with a unique identifier around each element markup, to separate the area of ββthe repeated identifier, making the repeat Identifier unique inside the containing div. This should allow javascript to remain relatively the same, with the exception that any references to the re-identifier should be covered by a specific DIV identifier
Taking into account that I want the result to be compatible with the browser, IE6 -IE9, Firefox 3+, Chrome, Safari, Opera, how reasonable does this approach sound? Will some browsers refuse repeated identifiers or behave badly with them? Any advice on a better approach or what I should pay attention to would be greatly appreciated. Thanks
----------------- adding ----------------------------- --- --------------------------------
It seems that the overwhelming consensus is that it is really a very bad idea to re-identify, mainly because the standards say that the identifier should be unique, and although some / most browsers support it now, there is no guarantee for the future. I completely agree with you on this.
The cool approach was apparently the best way to get the advice you got, but now it looks like older browsers don't support it, especially IE6 and 7. Any tips along the way from here?
----------------- adding ----------------------------- --- --------------------------------
In balance, getElementsByTagName seems to be the most compatible redirection method, also covering a wide range of mobile browsers.
Thanks for all your advice.