Sign in to follow this  

[web] Dynamic Html Tables

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Show some source from your own attempt and people will help you figure out what needs fixing, otherwise you're basically asking people to do it for you - and noone want's to do that. Also, clarify what exactly you want to change? Simply the data within the table, or the actual table itself (number of cells, layout, etc)?

Hints:
-You'll need to assign IDs where appropriate to refer to what you're changing.
-DIV (and to only a slightly lesser extent SPAN) are very useful.

__________________________
Google is your friend.

Share this post


Link to post
Share on other sites

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html><head>

<title>how to fill in a table...</title>
<meta http-equiv=content-type content='text/html; charset=UTF-8'>

</head><body onload="fillInTable();">

<script type="text/javascript">

var table =
{
foo: [2, 3, 4],
blah: ['cheese', 'grapes', 'wine'],
baz: ['insert', 'stuff', 'here']
};

function fillInTable()
{
var html = '<table>';

for(name in table)
{
html += '<tr><th>' + name + '<\/th>';

for(index in table[name])
html += '<td>' + table[name][index] + '<\/td>';

html += '<\/tr>';
}

document.getElementById('foobar').innerHTML = html + '<\/table>';
}

</script>

<div id="foobar">To be filled in by script.</div>

</body>


Share this post


Link to post
Share on other sites

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this