Solved

style sheet effect after the table is sorted

Posted on 2003-11-01
6
279 Views
Last Modified: 2010-04-09
I have a HTML table which is using an external stylesheet. The rows are sorted when the user clicks on the heading of the table. The problem is that after the rows are sorted the the style sheet does not show its effect and the page is displayed normally.
i ma doing
              var oldDsply = tblEl.style.display;
in the beginning of the javascipt function which sorts
and the following in the end of the function.
 tblEl.style.display = oldDsply;

But it doesn't work.
Please help
0
Comment
Question by:anshul9189
  • 3
  • 2
6 Comments
 

Author Comment

by:anshul9189
ID: 9662315
to be more specific
It is not working for only this class which I have in the external style sheet

.fontColor{
color: #003366;
font-family: Times;
font-size: 14;
}
For other classes it is working fine.
0
 

Author Comment

by:anshul9189
ID: 9662322
It doesn't work for the following class which is in the external style sheet.
.fontColor{
color: #003366;
font-family: Times;
font-size: 14;
}
I am using this class in the html page as follows
<font class=fontColor>text</font>
But this class does not display its effect after the rows are sorted. All other classes work fine.
0
 
LVL 2

Assisted Solution

by:ericsDev
ericsDev earned 150 total points
ID: 9665424
sort the rows and document.write them to the page. but instead of writing <font class=fontColor>text</font> write <font id="fontColor_X">text</font> where "X" is a counter variable that starts at 0 and goes to however many font tags are generated.  After the document.write is complete run a loop that looks something like this:

function setFontColor()
{
     var counter = 0;
     while(document.getElementById("fontColor_" + counter) != null)
     {
          document.getElementById("fontColor_" + counter).className = "fontColor";
          counter++;
     }
}

I believe this will work, let me know if it does not or if you see something wrong with my code.  It is untested at time of posting :)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Accepted Solution

by:
Zontar earned 220 total points
ID: 9668081
Using CSS for font tags is rather counterproductive, since the whole point of CSS is to *get rid* of things like font tags.

If you want to apply a style class to the text of a table cell, then use

<td class="fontColor">some text...</td>

If you want it to apply to all text in the table, then use

<table class="fontColor">
...
</table>

and define your style class like so:

table.fontColor td {...}

>  sort the rows and document.write them to the page

My guess is that this isn't what's happening, since using document.write()s within the page after it's loaded would clear it. I know that the way I'd do this would be to use DOM element removal/insertion/etc. methods on the table rows. If this is what's being done, then chances are that what's happening is that the font tags aren't being re-created. Which is good, as they shouldn't bloody well be there in the first place. :)

If this doesn't help, then please post the table and script code or a link to them so we can see what's actually going on here.
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9668114
> var oldDsply = tblEl.style.display;
> in the beginning of the javascipt function which sorts
> and the following in the end of the function.
> tblEl.style.display = oldDsply;
> But it doesn't work.

The display property has nothing to do with colours or style sheets apply to an element or anything like that. It controls what sort of box the element generates -- whether it's inline, block, etc.
0
 

Author Comment

by:anshul9189
ID: 9668671
thnks a lot
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to create a tile layout 1 38
SVG Star 4 35
Printing a Google Form 2 25
Disabled form text field 2 22
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now