Dynamic HTML table from array

Change content on the fly

Page 1 of 1

3 Replies - 3701 Views - Last Post: 10 May 2002 - 05:16 AM

#1 ibec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 01-May 02

Dynamic HTML table from array

Posted 09 May 2002 - 07:29 AM

When the content of an array changes (new field values, new entries, deleted entries), I want to see this reflected in a HTML table. The number of rows in the table should be the same as the number of entries in the array.

How do I do that?

Preferably with Javascript...


Is This A Good Question/Topic? 0
  • +

Replies To: Dynamic HTML table from array

#2 honkyinc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 08-May 02

Re: Dynamic HTML table from array

Posted 09 May 2002 - 08:10 AM

I might need more details on what you're trying to accomplish, but from what I gather from your post you would need to use a for statement to run through the array, each time printing out the appropriate TR, TD cells with the content of the array in it.

example:

for(i=0; i<array.length; i++)
{
document.writeln("<TR><TD>" + array(i) + "</TD></TR>");
}

Replace the "(" and ")" with regular brackets.

Then, whenever the amount of information in the array changes, so will the number of loops, hence keeping the output consistent with the array contents.

Hope this helps.

(Edited by honkyinc at 11:13 am on May 9, 2002)

Was This Post Helpful? 0
  • +
  • -

#3 ibec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 01-May 02

Re: Dynamic HTML table from array

Posted 10 May 2002 - 02:40 AM

I found a solution by rewriting the frameset:

parent.BAM_ALERT.document.open();
parent.BAM_ALERT.document.write('<html>');
...
parent.BAM_ALERT.document.close();

You can find the result on:

http://www.bam.nu/bam_demo_b2b.html

The alert-table works now context-sensitive on a selection in the B2B scheme.

Was This Post Helpful? 0
  • +
  • -

#4 honkyinc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 08-May 02

Re: Dynamic HTML table from array

Posted 10 May 2002 - 05:16 AM

Alrighty, apparently I had no idea what the #### you were talking about in your first post, so ignore my advice.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1