Hiya!

I'm working on converting an HTML document (AmCharts Pie) to all JavaScript for work, and I ran into a bit of a bump. (NOTE: I'm not a Javascript programmer)

Okie - my question is this: Is there a JavaScript equivalent to the HTML Div tag? Here's a piece of the code:

<head>
    <script src="../amcharts.js" type="text/javascript"></script>        
</head>
<body>

AmCharts.ready(function() {
   ......
   chart.write("chartdiv");
});

<div id="chartdiv" style="width: 100%; height: 400px;"></div>
</body>

What I'm trying to convert it to doesn't except HTML files, only JS, so if I can't convert it, looks like I'll be looking for a new pie chart :)

Thanks in advance!

Cassie :)

I'm trying to create a JS file, and stay away from HTML. There is a part of what I'm making that accepts lines of HTML, but it's in an XML file, and it's not doing what the div is supposed to do.

Member Avatar for stbuchok

You can use createElement(), however, chances are you are going about this all wrong. Can you explain in detail exactly what needs to happen (not what you are doing)? What is the problem you are ultimately trying to solve?

The problem I was trying to fix was getting the chart to draw on the screen. I tried a couple of things in the HTML file (i.e. taking the div tag out), and the chart broke without it.

So basically, the DIV tag is creating the place holder and when the chart is written, it's going to that div. I found a quick fix for now (adding the div to the XML file), but that's not what I want to end up doing.

Member Avatar for stbuchok

Still not sure what you are trying to do really, but the createElement() method will be able to create a div (or any other element) using JavaScript. You'll just need to remember to append that div to another element in order for it to show on the page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.