Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Javascript html dynamic rendering

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!
Avatar of Gary
Gary
Flag of Ireland image

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

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

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

Open in new window

Avatar of Isaac

ASKER

i tried that before asking for help but it did not work.

Also, isn't there a downside to using document.write
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial