By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

innerHTML = JavaScript object

P: n/a
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
Oct 4 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
KDawg44 <KD*****@gmail.comwrites:
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.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Oct 4 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.