Jump to content
  • Advertisement
Sign in to follow this  
dr_slash_uh

[web] Dynamic Html Tables

This topic is 5150 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

I am trying to create a table that can be changed with javascript. Similar to how you can change a text box. Help would be greatly appreciated. God Bless

Share this post


Link to post
Share on other sites
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!