innerHTML = JavaScript object

K

KDawg44

HI,

I am using jsgraph to draw some graphs. I want to be able to update
these graphs by calling a javascript function to update data.

I have a div to display the graph that looks like this:

<div id = 'div1'>
<script language="JavaScript">
<!--
graph3.makeGraph();
//-->
</script>
</div>

What I would like to do is from another javascript function

document.getElementById('div1').innerHTML = graph3.makeGraph();

but this does not work. Is there a way to output a javascript object
to a div?

Thanks.

Kevin
 
J

Joost Diepenmaat

KDawg44 said:
HI,

I am using jsgraph to draw some graphs. I want to be able to update
these graphs by calling a javascript function to update data.

I have a div to display the graph that looks like this:

<div id = 'div1'>
<script language="JavaScript">
<!--
graph3.makeGraph();
//-->
</script>
</div>

What I would like to do is from another javascript function

document.getElementById('div1').innerHTML = graph3.makeGraph();

but this does not work. Is there a way to output a javascript object
to a div?

If you set innerHTML to a string containing a valid HTML snippet, it
will work. where that string came from is irrelevant.

I suspect your graph3.makeGraph() does not return a string, but calls
document.write() instead - which you cannot for this after the document
has loaded. So change that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top