Solved

style sheet effect after the table is sorted

Posted on 2003-11-01
6
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Accordion won't close correctly 5 17
Html split(text) Part2 6 38
Ajax on ASP 2 65
Sending HTML Formatted Email from ASP.NET 2 50
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

738 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