Solved

style sheet effect after the table is sorted

Posted on 2003-11-01
6
275 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

708 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

20 Experts available now in Live!

Get 1:1 Help Now