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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spiderman2
    New Member
    • Oct 2007
    • 1

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

    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.getEle mentsByName("ch kBox") 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.getEle mentsByName("ch kBox") doesn't select them. I tried the .name="blah" on the checkbox object but did not work. I'm using IE 6.
    Please explain.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    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

    Comment

    Working...