?
Solved

Javascript html dynamic rendering

Posted on 2014-10-03
3
Medium Priority
?
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

752 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