Forum Moderators: open

Message Too Old, No Replies

Javascript - changing an elements ID

Is there a way to change an ID once set?

         

shaggydoo

5:26 pm on Nov 3, 2006 (gmt 0)

10+ Year Member



My page has a series of rows and cells that a user can navigate through using their arrow keys via javascript.

Using get id, i could pick the next row easily since the ID of each cell was created using Group, Row, Cell:

g1_r1_c1, g1_r1_c2, g1_r1_c3
g1_r2_c1, g1_r2_c2, g1_r2_c3
g1_r3_c1, g1_r3_c2, g1_r3_c3
....
g2_r1_c1, g2_r1_c2, g2_r1_c3
g2_r2_c1, g2_r2_c2, g2_r2_c3
g2_r3_c1, g2_r3_c2, g2_r3_c3
...
and so on.

Now I am trying to use ajax to add new rows, but sometimes the new row should appear between existing rows.
so if a row is added after group 2, row 2, I would like to give it and id of
g2_r3_c...
and then change all the cells in row 3 to row 4 and so on.
Though I would have to do this in a slightly different order to avoid two elements with the same id.

Anyone have any luck with something like this, or is there a better way to navigate around a grid of cells?

shaggydoo

5:42 pm on Nov 3, 2006 (gmt 0)

10+ Year Member



well I guess it was easier then I thought.

function changeID(obj){
obj.id = '123' + obj.id
}