Table sorting using Javascript
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Saravanan_Parameswaran
Posted On:   Friday, September 13, 2002 02:12 PM

function sortBy(col) { tab=(document.getElementById)?document.getElementById("data"):document.all.data; var arr=new Array(); var arr2=new Array(); for (i=1;i arr[i-1]=tab.rows[i].cells[col].innerHTML+i; arr2[i-1]=tab.rows[i].innerHTML; } arr.sort(trueSort); for (i=1;i var num=arr[i-1].length; tab.rows[i].innerHTML=arr2[(arr[i-1].substr(num-1))-1] alert(tab.rows[i].innerHTML) } } function trueSort(a, b) { if (a.toLowerCase() > b.toLowerCase()) { return 1; } else if (a.toLowerCase() return -1; } else if (a.toLowerCase()==b.toLowerCase()) { return 0; } } ]]>]]> The below code sorts a JSP table using javascript. It is showing some run time error in the line tab.rows[i].innerHTML=arr2[(arr[i-1].subs   More>>
			
The below code sorts a JSP table using javascript.
It is showing some run time error in the line
tab.rows[i].innerHTML=arr2[(arr[i-1].substr(num-1))-1]. Can anyone rectify the problem and help me?

This is the code:


			







				

Test Page

					






























FIRST NAME Middle Name LAST NAME AGE
Anton Marc HoSang 28
George Doublya Bush 55
James idiot Bond 41





   <<Less
About | Sitemap | Contact