Hai ,
I have a table in php where the rows are displayed dynamically.
I need to move the rows up and down according to the click.How can i get this?I tried with innerHtml also. But I am unable to get the solution.
Regards
Anu
move table rows up and down
Moderator: General Moderators
Re: move table rows up and down
After sorting in php array ( if you use one ) refresh the whole table --- if your apps is localhost you hardly see the delay
IF you use js prototype you can use library scriptaculous it has a sort function ( the cool one )
innerHTML should work too.
IF you use js prototype you can use library scriptaculous it has a sort function ( the cool one )
innerHTML should work too.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
I think you could use something like this:
This exchanges row [the_desired_row] with [the_other_desired_row].
Code: Select all
var my_table = document.getElementById('my_table');
temp1 = my_table.getElementsByTagName('tr')[the_desired_row].innerHTML;
my_table.getElementsByTagName('tr')[the_desired_row].innerHTML = my_table.getElementsByTagName('tr')[the_other_desired_row].innerHTML;
my_table.getElementsByTagName('tr')[the_other_desired_row].innerHTML = temp1;-
webadmin40
- Forum Newbie
- Posts: 5
- Joined: Wed Jul 21, 2010 4:07 am
Re: move table rows up and down
@ Jonah Bron: Sincere thanks. I had been facing almost a similar problem since a long time. I searched for solutions almost everywhere but this was no help. This one piece of code worked wonders for me. It was so important for me to shift the table rows up and down and i just can't tell you how relieved i am after getting a solution to this. Keep up the good work. Cheers..!!