...

View Full Version : Graphic unable to render unless i have document.write in body.. argh!



meats
04-22-2009, 02:57 PM
Apologies for my first post, I'm having a hard time rendering the graphic from the sparkline plugin unless I have document.write('') in the body. Whenever I pull that out, the little chart rendered from the plugin no longer works and its baffling to me.

How can I get the graphic to render without having that superfluous document.write in there?

Feel free to critic this code, I'm sure there are a handful of errors.



<html>
<head>
<script type="text/javascript" src="http://omnipotent.net/jquery.sparkline/jquery-1.2.6.js"></script>
<script type="text/javascript" src="http://omnipotent.net/jquery.sparkline/1.4.1/jquery.sparkline.js"></script>

<script type="text/javascript">
var string = new Array();

function displayResults(query) {
var script = document.createElement('script');
script.setAttribute('src', 'http://spreadsheets.google.com/feeds/cells'
+ '/' + 'pxh9i2raqICC7emBKMcrnUA'
+ '/' + 'od6' + '/public/values' +
'?alt=json-in-script&callback=cellEntries');
script.setAttribute('id', 'jsonScript');
script.setAttribute('type', 'text/javascript');
document.documentElement.firstChild.appendChild(script);
}

function cellEntries(json) {
for (var i=0; i < json.feed.entry.length; i++) {
string[i] = json.feed.entry[i].content.$t;}
}

$(function() {
$('.inlinesparkline2').sparkline(string, {type: 'tristate'});
});

</script>
</head>
<body>
hello1
<script type="text/javascript">
displayResults();
</script>
hello2
<script type="text/javascript">
document.write('');
</script>
hello3
<span class="inlinesparkline2">Loading..</span>

</body></html>

meats
04-22-2009, 07:17 PM
mods, can you move to main forum?

Even though my code contains JSON parts, my question does not specifically relate to that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum