You haven't provided specific details about the issue at hand ("playing up" is quite vague ;)), and you didn't mention which versions of Internet Explorer you're encountering this problem with, but I presume it's IE9 or an earlier version.
The issue likely stems from the fact that document.getElementsByName()
is flawed and not properly supported in IE9 and earlier versions (although it works fine in IE10).
For a comprehensive browser compatibility chart, check out this link, which also highlights the known bugs in IE.
The solution will vary depending on the versions of IE you need to cater to.
If you're okay with supporting IE8 onwards, consider using document.querySelectorAll()
instead. This method allows you to select elements using CSS selectors, such as:
var inputs = document.querySelectorAll('[name=attname\\[\\]]');
This serves as a direct substitute for your current getElementsByName()
approach, functioning effectively in IE8 and upwards, as well as in all other browsers.
Note that when using this syntax, you must escape the []
characters with backslashes due to their significance in CSS. The doubled-up backslashes are needed because backslashes in Javascript strings require escaping as well.
It's worth noting that this method won't work in IE7 since it lacks support ((refer to this [browser support information](http://caniuse.com/queryselector))), so if IE7 compatibility is necessary, exploring alternative solutions may be required. One suggestion would be utilizing a library like jQuery to simplify working around IE7's limited DOM capabilities. Alternatively, dropping support for IE7 altogether could be a viable option.