lu13cky Posted May 27, 2010 Share Posted May 27, 2010 I know how to do wonderful alternating row colors, but is there a way to do alternating column colors? Link to comment Share on other sites More sharing options...
thescientist Posted May 27, 2010 Share Posted May 27, 2010 probably in the same way people do rows. assign classes to <td>'s based on an odd or even iterator value (assuming you are doing it in a loop). Link to comment Share on other sites More sharing options...
lu13cky Posted May 27, 2010 Author Share Posted May 27, 2010 probably in the same way people do rows. assign classes to <td>'s based on an odd or even iterator value (assuming you are doing it in a loop).yeah I've attempted it...annnnd it just turns my columns into rows.hah. I'll mess around with my code a bit more I guess to achieve it. Link to comment Share on other sites More sharing options...
thescientist Posted May 27, 2010 Share Posted May 27, 2010 If you're columns are turning themselves into rows, then it sounds like your table is being outputted incorrectly. Link to comment Share on other sites More sharing options...
ShadowMage Posted May 27, 2010 Share Posted May 27, 2010 Maybe post some code? Link to comment Share on other sites More sharing options...
thescientist Posted May 27, 2010 Share Posted May 27, 2010 a wise man once said: never stand behind a sneezing cow.your Dad again? Link to comment Share on other sites More sharing options...
dsonesuk Posted May 27, 2010 Share Posted May 27, 2010 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script type="text/javascript">/*<![CDATA[*//*---->*//*--*//*]]>*/</script> <style type="text/css">table.mytable {margin:0 auto;}.tdcol1, .tdcol2 {width:100px; text-align:center;}.tdcol1 {background-color:#CCFFCC;}.tdcol2 {background-color:#FFFF99;}</style></head><body><?php$tdcount=4;$trcount=4;?><table cellpadding="0" cellspacing="0" border="1" class="mytable"><?phpfor($i=0;$i<$trcount;$i++){echo '<tr>';for($j=0;$j<$tdcount;$j++){if($j%2==0){$tdcol="tdcol1";}else{$tdcol="tdcol2";}echo '<td class="'.$tdcol.'">'.($j+1).'</td>';}echo '</tr>';}?></table></body></html> Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2010 Share Posted May 27, 2010 <script type="text/javascript">/*<![CDATA[*//*---->*//*--*//*]]>*/</script>I keep seeing this in all the threads you reply and I'm confused. Could you explain what it's for? Link to comment Share on other sites More sharing options...
real_illusions Posted May 27, 2010 Share Posted May 27, 2010 Get rid of classes with the Nth CSS:tr:nth-of-type(even){background:#e0d3c7;}Only works in browsers that support CSS3 though Link to comment Share on other sites More sharing options...
dsonesuk Posted May 27, 2010 Share Posted May 27, 2010 I just keep it in pages, to see how long it would take for someone to ask what is <script type="text/javascript">/*<![CDATA[*//*---->*//*--*//*]]>*/</script>for?and guess what! you win the prize Link to comment Share on other sites More sharing options...
ShadowMage Posted May 27, 2010 Share Posted May 27, 2010 your Dad again? :)Nope, this one goes way back. It's a farmer's motto. Link to comment Share on other sites More sharing options...
ShadowMage Posted May 27, 2010 Share Posted May 27, 2010 I keep seeing this in all the threads you reply and I'm confused. Could you explain what it's for?I've never seen it like that, but I use something similar to tell the w3 validator to ignore my java script:<script type='text/javascript'>//<![CDATA[//]]></script>Without that, the w3 validator complains about < and > anywhere in the script, ie if (aVariable<anotherVariable) { Link to comment Share on other sites More sharing options...
dsonesuk Posted May 27, 2010 Share Posted May 27, 2010 I got it from http://www.giantisland.com/Resources/JavaS..._and_CDATA.aspx and hacked dreamweaver to insert it automatically in all new pages, might be out of date now! have not checked for years now Link to comment Share on other sites More sharing options...
justsomeguy Posted May 27, 2010 Share Posted May 27, 2010 It's not necessarily wrong to have that there, that page is talking about doing that to "hide" the Javascript code from an XML parser if your page is served as XHTML or XML+HTML. There's another discussion about it here:http://javascript.about.com/library/blxhtml.htmIt's probably not necessary to include all of the extra comments around it though, several sites like that talk about doing that to support "older" web browsers, but the fact is that in these days no one uses a browser that doesn't understand what you're trying to do. Even IE6 should support a normal cdata tag, so it's probably not necessary to hide it with Javascript comments. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.