wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes dynamic display of a row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "dynamic display of a row" Watch "dynamic display of a row" New topic
Author

dynamic display of a row

preethi venkatarangan
Greenhorn

Joined: Jan 21, 2007
Posts: 27
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

Joined: Feb 22, 2005
Posts: 261
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic display of a row
 
Similar Threads
Regarding JTable mouse events
how to show/hide textfield for each click
onclick of hyperlink
how to show same row for each click on a link
help on html:link action