PDA

View Full Version : Related Javascript Objects


mrhatch
03-28-2003, 07:01 PM
All,

I am working on a javascript replication of the sort graphics similar to what is displayed in Outlook. At the top of each column will be a label that has the column name and a graphic. When you click the column, it calls to another script to sort the table in descending order and changes the graphic to a down arrow. A second click on the same column header will resort the table in ascending order. I have been able to code this in an object with out much problem. My only glitch is the following:

I need to relate the columns so that when you click on another column it resets the graphic on the column last sorted to the default position then sets the new sort status on the new column. To complicate this even more, I need to make this code compatible with NN4.x and IE4.x.

I can post the code for the object if anyone is interested, but would rather wait until the whole thing is working.

TIA
Michael Hatch

RoyW
03-28-2003, 07:14 PM
without seeing code all I can do is make a suggestion.

Use a global variable to store the id of the image that is changing. You can then check this to see if a different column (different image id) has been clicked and reset the old one.


var last_id = null;

function clicked(id)
{
if(last_id != null)
if(id != last_id)
document.images[last_id].src = "default_image.jpg";

last_id = id;
}