Board Logo

REALLY dynamic tables
cpi - 6/29/2006 at 05:15 AM

Why this don't work? How can i build REALLY dynamic tables on the fly?

Quote:
<html>
<head>
<title>Untitled</title>
<link rel="stylesheet" href="../css/table.css">
<script language="JavaScript" src="../js/table.js"></script>
<script language="JavaScript" src="../js/template.js"></script>
</head>
<script type="text/javascript">
var TABLE_CONTENT3;
var TABLE_CONTENT = [
['these are', 'top', 'frozen', 'cells'],
["copyright", "ABRAMOWICHM", 58, 665],
["copyright", "ADAMS", 67, 1558],
["dayz1_", "ADAMS", 88, 23746],
["rhit1s", "ADAMS", 74, 293772],
["kokain", "AGEEV", 67, 348304],
["agauth", "AGEEV", 48, 0],
["nab1", "AGEEV", 47, 0],
["dezmash", "AKONANDOJL", 123, 32780],
["sh_fivez", "AKONANDOJL", 69, 39215],
["sh_fneng", "AKONANDOJL", 71, 42557],
["sh_gar", "", 72, 38667],
["annotations", "AKSENOW", 52, 4282],
["apelxsin", "AKSENOW", 68, 234038],
["wanderer", "AMNUEL", 56, 36826],
["war_2029", "AMNUEL", 62, 21583],
["yes-no", "AMNUEL", 59, 38333],
["BytTrusom", "ANDERSON", 99, 51943],
["ChertogiMerfi", "ANDERSON", 109, 34111],
["DenPrichastiya", "ANDERSON", 61, 104965],
['these are', 'bottom', 'frozen', 'cells']
];

function change3(){
TABLE_CONTENT3 = '[';
for (i=0; i<=3; i++ ){
TABLE_CONTENT3 = TABLE_CONTENT3 + '[';
for (j=0; j<=3; j++ ){
TABLE_CONTENT3 = TABLE_CONTENT3 + i + j + ',';
}
if (i<3) TABLE_CONTENT3 = TABLE_CONTENT3 + '],';
else TABLE_CONTENT3 = TABLE_CONTENT3 + ']';
}
TABLE_CONTENT3 = TABLE_CONTENT3 + ']';

alert('TABLE_CONTENT3 = ' + TABLE_CONTENT3);

tabla.changeCont('TABLE_CONTENT3',6);
}
</script>

<body>
<p>Please, click 'change3' button... <br> Why this don't work? How can i build REALLY dynamic tables on the fly?</p>
<input type="button" name="change3" value="change3" onClick="change3()" />
<div id="query" style="border-width:thin; border-color:silver; border-style:groove;">
<SCRIPT LANGUAGE="JavaScript">
var tabla = new TTable(TABLE_CAPT, TABLE_CONTENT, TABLE_LOOK);
</SCRIPT>
</div>
</body>

</html>


tigra - 9/14/2006 at 06:54 PM

You generate TABLE_CONTENT3 as the string, it should be array. You can either change your code to generate it as the array or eval it.


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/