Solved

Javascript html dynamic rendering

Posted on 2014-10-03
3
125 Views
Last Modified: 2014-10-03
What's the best way to render the below(buildTargetTable()) to the browser?  I'm trying to build a table on the fly as the page is getting rendered.

The below works but only if I alert it or console.log it.  What I want to do is make it render to the browser.

<!DOCTYPE html>

	<script LANGUAGE="JavaScript">

function buildTargetTable(tblType)
{
	var tbl = "";
	
	tbl = "<Table id="+tblType+"></Table>";
	return tbl;
}

buildTargetTable("PBC");

buildTargetTable("Sample");

buildTargetTable("Whatever");

</script>

Open in new window


Any ideas?

Thanks!
0
Comment
Question by:Isaac
  • 2
3 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40360261
document.write (buildTargetTable("PBC"));

document.write (buildTargetTable("Sample"));

document.write (buildTargetTable("Whatever"));

Open in new window

0
 
LVL 5

Author Comment

by:Isaac
ID: 40360263
i tried that before asking for help but it did not work.

Also, isn't there a downside to using document.write
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40360268
Well you won't see anything in the browser just using
tbl = "<Table id="+tblType+"></Table>";
as the tables don't contain anything, you need at least one row and one cell
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question