Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Dynamic HTML Tables: Improving Performance
Subject:   How to change the element names after a new element is inserted in between the cells.
Date:   2005-06-19 21:02:04
From:   Hava
Hello,
I have a table with text boxes in it.
user can insert text boxes. when they insert new text boxes, i need to rename all the text boxes in the table, so that all the names are unique.
How can i do this, by traversing the table.
Thanks in advance.
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • How to change the element names after a new element is inserted in between the cells.
    2005-06-23 15:21:38  Danny Goodman | O'Reilly Author [View]

    Your approach depends on the other element in the table, but the first goal is to obtain references to all text box elements in the table. If the form begins and ends within the table, then you can use the document.formName.elements[] array to obtain an array of all elements, and then, as you loop through the elements array, modify the name properties of those elements whose type property is "text".

    A more modern (DOM) approach is to use getElementsByTagName("INPUT") of the table element, and then loop through that array, also changing the name properties of those elements whose type property is "text".