Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1462 How do I build a 10 times table in JavaScript where the numbers divisible by X are highlighted?

irt.org | Knowledge Base | JavaScript | Table | Q1462 [ previous next ]

Q1462 How do I build a 10 times table in JavaScript where the numbers divisible by X are highlighted?

Try:

<script language="JavaScript"><!--
var X = 7;
var Text = '<table><tr>';
var Cells = 100;

for (i=1;i<=Cells;i++) {
  if (i%X==0) Text += '<td><font color="red">' + i + '</font></td>';
  else Text += '<td>' + i + '</td>';
  if (i%10 == 0 && i<Cells) Text += '</tr>\n<tr>';

}
Text += '</tr></table>'
document.write(Text);
//--></script>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.