|
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>
|
|
|
Copyright © 1996-2009 irt.org, All Rights Reserved.