[thelist] check all checkboxes, DOM etc

Tom Dell'Aringa pixelmech at yahoo.com
Thu Sep 19 13:43:01 CDT 2002

I'm working up a demo for a client where I am using the DOM to
dynamically add rows to a table, each row has a checkbox.

At the top, you can click a checkbox to select ALL the checkboxes. I
am using this function:

function checkAllBoxes(targetform)
  for (i = 0; i < targetform.elements.length; i++)
    if (targetform.elements[i].type == "checkbox")
      if(targetform.elements[i].checked == false)
        targetform.elements[i].checked = true

Seems it should work, and it does when I first load the page with
only 1 default row. But once I add rows, it doesn't work. It almost
seems as if it doesn't see the new rows and checkboxes. Here is a
typical row (in fact the default row)

<td width="16"><img src="view.gif" width="14" height="14" alt=""
<td width="16"><input type="checkbox" id="fern"
<td><label for="fern">Fernandez, Carlos</label></td>
<td>Neptune, NJ</td>

The checkbox is added with this line from a DOM JS function:

cell.innerHTML = "<input type=\"checkbox\" id=\"box1\"
class=\"checkbox\" />";

and they do show up..any ideas??


var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

More information about the thelist mailing list