gaea 0 Report post Posted April 3, 2006 There is probably a mind numbingly easy way to do this...but it's driving me nuts. Basicly I use javascript to write out a varaible <script src="http://antiwar.com/ewens/counter/casualties.js"></script><script>document.write(casualties.total_value);</script> So good so far. But then I want to formatt in in a specific way using css. But I can't get it to actually change the formatting.I tried:<script src="http://antiwar.com/ewens/counter/casualties.js"></script><script>document.write(<font STYLE=font-family: Arial; font-size:12pt> +casualties.total_value+</font>);</script>as well as using the <div> tag, and even setting the <td STYLE=> (forgot to mention that it's in a table).All of that doesn't make any change. This is starting to get really obnoxious. Any help would be appreciated. Share this post Link to post Share on other sites
Tyssen 0 Report post Posted April 3, 2006 You can't use JS to document.write styles to the head of the document but rather you use it to change pre-existing styles on your page. For instance, if you have a div called #content on your page, you can do something like: var myDiv = getElementByID('content');myDiv.style.background-color = '#FFF'; Share this post Link to post Share on other sites
gaea 0 Report post Posted April 3, 2006 (edited) Thanks for the tip...but that's not exactly what i meant. I wasn't trying to write new styles to the header, only trying to get the text created by document.write to follow the formatting rules of my stylesheet. Anyways, I resolved that issue by creating the table cell in the document.write call. document.write('<td class="counters" width=45 height=3 border=3 bordercolor=#000000>'+casualties.total_value+'</td>'); Only problem now is that it is completely ignoring the hight, width, and border values. Quite strange. Maybe it's just me, but javascript seems a great deal more fickle than something like php. I always run into the weirdest of problems. Edited April 3, 2006 by gaea (see edit history) Share this post Link to post Share on other sites
Tyssen 0 Report post Posted April 3, 2006 Maybe it's just me, but javascript seems a great deal more fickle than something like php. I always run into the weirdest of problems.Yeah, JS isn't my strong suit either. Share this post Link to post Share on other sites
Inspiron 0 Report post Posted April 4, 2006 If you are unable to write the text that is styled as what it's been configured to, you can try the following. <span style=”font-family: Arial; font-size:12pt”> <script src="http://antiwar.com/ewens/counter/casualties.js"></script> <script>document.write(casualties.total_value);</script></span> This code make sures that whatever text that is inside the span division will be styled as configured. Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted April 4, 2006 Or use classes? In the html:<span class=?special?><script src="http://antiwar.com/ewens/counter/casualties.js"></script><script>document.write(casualties.total_value);</script></span>In the Css:.special { font-family: Arial; font-size:12pt; } That takes the formatting out of the document and places it into the css file. Makes it more readily changed for the skin or template. Share this post Link to post Share on other sites