Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Graphic unable to render unless i have document.write in body.. argh!

    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.

    Code:
    <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>

  • #2
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mods, can you move to main forum?

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •