this code don't avoid repetition <!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> <title></title> <script type="text/javascript"> window.onload = function() { var table1 = document.getElementById("table1"); var rgb = {"red":255, "green":255, "blue":255};// rgb = getNewColor(rgb); alert(table1.rows.length) for(var i = 0; i < table1.rows.length; i++) { rgb = getNewColor(rgb); var red = rgb["red"].toString(16); var green = rgb["green"].toString(16); var blue = rgb["blue"].toString(16); var newcolor = "#" + (red.length == 1 ? ("0" + red) : red) + (green.length == 1 ? ("0" + green) : green) + (blue.length == 1 ? ("0" + blue) : blue); table1.rows[i].style.backgroundColor = newcolor; // alert( newcolor) } } function getNewColor(rgb) { var color = Math.round(Math.random() * 255); while(Math.abs(rgb["red"] - color) < 50) { color = Math.round(Math.random() * 255); } rgb["red"] = color; color = Math.round(Math.random() * 255); while(Math.abs(rgb["green"] - color) < 50) { color = Math.round(Math.random() * 255); } rgb["green"] = color; color = Math.round(Math.random() * 255); while(Math.abs(rgb["blue"] - color) < 50) { color = Math.round(Math.random() * 255); } rgb["blue"] = color; return rgb; } </script> <style> td{ height:10px; } </style> </head> <body> <table id="table1" border="1" style="width:100%; height: auto" > <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> </table> </body> </html> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Chart API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-chart-api?hl=en -~----------~----~----~----~------~----~------~--~---
