Solved

Javascript html dynamic rendering

Posted on 2014-10-03
3
120 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now