Dynamically Add Table Rows

[Total: 0    Average: 0/5]

This example illistrates how to have table rows altered dynamically.

Head Code:

<script  language="JavaScript" src="http://www.js-examples.com/bin/div_construct2.js"></script>
<script>
var _start = '<a href="javascript:newOne()">click to start</a>';
var _link = '<a href="javascript:newOne()">click to add one</a>';
var _m1='<table width="100%" height="100%" border="0"><tr><td align=center><a href="javascript:newOne()">click to start</a></td></tr></table>';
var div1 = new NewDiv2(window,"d1",_m1,10,10,500,50,10,true);</script>

Body Code:

This example might have a syntax error as it is run from this site (from inside this site).
It works - download the code from the "view code" page and run it.
<script>
div1.output();
var counter=1;
function newOne() {
  counter++;
  _m1  = '<table width="100%" height="100%" border="1">';
  for (var i=0;i<counter;i++)
    _m1 += '<tr><td align="center" valign="middle">'+(i+1)+': '+_link+'</td></tr>';
  _m1 += '</table>';
  div1.setBody(_m1);
  div1.show();
}
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *