Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic display of a row

 
preethi venkatarangan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a row with textfield and a hyperlink.
I have another row with another textfield.
by default i show the first row with the textfield and hyperlink.
now when i click the link i want to show the second row with the textfield..So far fine.but when i click the link again i want to show the same row again that is the second row.I want that row to be displayed each & every time the link is clicked .how do i do this dynamically using jsp & javascript.

It would be nice if someone could provide me with a simple example of how to achieve this.

thanks in advance
[ February 10, 2008: Message edited by: Bear Bibeault ]
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 ways (that I've figured so far) to go about this.
1 => you can try altering the innerHTML value for the table.
2 => you can create a "tr" node element and append it to the table node

For 1:
Instead of adding one "tr" at a time, it would be convenient if you add a table (containing a single "tr") everytime. Create a DIV to store all possible table data.
Store the HTML content of your row in a Javascript variable. Something like:


I'll only like to forewarn you that in this approach, the value stored in the elements of previous rows will be reset as you're actually repainting the whole content of the DIV again.

For 2:
Create a "tr" node using..

Create nodes for every constituent of the "tr" similarly.
Then get a reference to the "table" to which you need to append the row, and use...


The flipside to this approach is that for a complex row structure, the creation of node elements can *really* get to be a pain. But since, the structure of your add rows is much simpler, you might want to consider this approach.
[ February 10, 2008: Message edited by: Anirvan Majumdar ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic