Solved

style sheet effect after the table is sorted

Posted on 2003-11-01
6
288 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

809 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