Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

problem with javascript sorting

Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,

I wanted add up && down icons to my theads,while sorting
my code is as follows.for ascending up arow,for descending down arow like that.
my code is as follows

<html xmlns="" xml:lang="en" lang="en">


<script language="JavaScript" type="text/javascript">

function zxcSortTable(zxcid,zxccnus){
var zxcargs=zxcSortTable.arguments
var zxctable=document.getElementById(zxcid);
var zxcrows=zxctable.rows,zxcscells=[],zxcclones=[],zxcblanks=[],zxccnt=0;
for (var zxc0=1;zxc0<zxcargs.length;zxc0++){
for (var zxc0a=1;zxc0a<zxcrows.length;zxc0a++){
var zxccells=zxcrows[zxc0a].cells;
var zxcdata=zxccells[zxcargs[zxc0]];
if (/[a-z]|[0-9]/i.test(zxcdata)){
if (!zxcrows[0].cells[zxcargs[1]].ud) zxcrows[0].cells[zxcargs[1]].ud='Up';
if (zxcrows[0].cells[zxcargs[1]].ud=='Up') zxcclones=zxcclones.reverse();
for (var zxc1=0;zxc1<zxcclones.length;zxc1++){

function zxcSortTxt(zxca,zxcb){
if (zxcaa>zxcbb) return 1;
if (zxcaa<zxcbb) return -1;
return 0;


any one please help me.
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where did you learn to name your variables? Looking at that code gives me a headache. Go back and use descriptive variables and you will get more help. And indentation helps too. I would like to help you but I can't take the kind of time it would require to figure out those names.
Posts: 15385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because he did not write the code...

Did you ask vwphillips about your issue?

Not sure what would be hard about it. You would have to add an image to each column and set the source

document.getElementById("sortImg" + colNumber).src = "myDirectionImage.gif";

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!