By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,930 Members | 1,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,930 IT Pros & Developers. It's quick & easy.

How can I change the name of a HTML checkbox using javascript

P: 1
When the page is first accessed, certain HTML elements are dynamically created. The checkboxes all have the name "chkBox". There is a special "checkAll" checkbox which when checked or unchecked, does the same operation on all the "chkBox" elements. It gets them by calling document.getElementsByName("chkBox") and then modifies their status. Now I have a requirement to bypass some of the checkboxes. Being too lazy to maintain a separate bit array that specifies whether or not a checkbox is to be bypasses, I want to simply change their names at runtime so that the document.getElementsByName("chkBox") doesn't select them. I tried the .name="blah" on the checkbox object but did not work. I'm using IE 6.
Please explain.
Oct 3 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 5,329
hi ...

IE doesn't allow you to set the name-attribute at runtime. have a look here ... but you may set a style-class that you may use to identify the boxes or simply use a custom attribute for that. custom attributes make your html invalid but i would prefer that way because of the right semantic use of them ... instead you may misuse the class attribute for that ...

kind regards
Oct 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.