For loop (JavaScript).. iterate over values held in bindings..?
<p>I am trying to iterate over the values in</p>

<ul>
<li>oldData.results.bindings.date</li>
<li>oldData.results.bindings.liability</li>
<li>oldData.results.bindings.stock</li>
<li>oldData.results.bindings.event</li>
<li>oldData.results.bindings.current</li>
</ul>

<p>...with all of the values. I'd like to document.write them all (while i is 'equal to' or 'less than' oldData.results.bindings.length), with an output, such as:</p>

<pre><code>document.write(simpleHead[0] +
  '{Date: "' +
  oldData.results.bindings[0].date +
  '", Liability: ' +
  oldData.results.bindings[0].liability +
  ", Stock: " +
  oldData.results.bindings[0].stock +
  ", " +
  oldData.results.bindings[0].event +
  ": " +
  oldData.results.bindings[0].current +
  ",}" +
  simpleTail[0]);
</code></pre>

<p><strong>Currently, I am only getting one of the data sets to print with '...[0]...'</strong> (as seen in the script above), but <strong>I would like to use a loop that writes '...[i]...'</strong> for each of the data sets.</p>

<hr>

<p><strong>Current code:</strong></p>

<pre><code>...
function httpGet(theUrl)
{
var xmlHttp = null;
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();         // instantiate request
xmlHttp.open( "GET", theUrl, false );   // open url
xmlHttp.send( null );                   // sending nothing
return xmlHttp.responseText;            // return url's data as text
};

var result = httpGet("#local#");        // assign this url to the variable name "result"

function revive (key, value) {
    if (value.datatype == "http://www.w3.org/2001/XMLSchema#double" ||  // if datatype is this
    value.datatype == "http://www.w3.org/2001/XMLSchema#integer" ||     // or, this
    value.datatype == "http://www.w3.org/2001/XMLSchema#float")         // or, this
    {
        return (parseInt(value.value))      // if '#double', '#integer', or '#schema', then: 'vars' label + convert the datatype's float value to integer 
    }
    else if (value.type == 'literal')
    {
        return (value.value)        // if datatype's value is a literal: 'vars' label + return as a string
    }
    else if (value.datatype == 'http://www.w3.org/2001/XMLSchema#date') 
    {
        return value.value      // if "XMLSchema#date's" value is a literal: 'vars' label + return as a string
    }
    else 
    {
        return value        // if datatype is anything else: 'vars' label + return value as a string
    }
};
var scriptHead = ["YUI().use('charts',function(Y){var myDataValues=&lt;br /&gt;&lt;br /&gt;["];
var scriptTail = ["&lt;br /&gt;];&lt;br /&gt;&lt;br /&gt;var styleDef={series:{Stock:{line:{color:'#EEB647'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#222',alpha:0,wmode:'transparent'},over:{fill:{color:'#eee'},border:{color:'#000'},width:9,height:9}}},Liability:{line:{color:'#171944'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#222',alpha:0,wmode:'transparent'},over:{fill:{color:'#eee'},border:{color:'#000'},width:9,height:9}}},Shipment:{line:{color:'#ff0000',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#ff0000',alpha:0,wmode:'transparent'},over:{fill:{color:'#ff0000',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}},Production:{line:{color:'#FFD700',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#FFD700',alpha:0,wmode:'transparent'},over:{fill:{color:'#FFD700',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}},Order:{line:{color:'#006400',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#006400',alpha:0,wmode:'transparent'},over:{fill:{color:'#006400',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}}}};var myAxes={dateRange:{keys:['date'],position:'bottom',type:'category',title:'Date Range',styles:{majorTicks:{display:'none'},label:{rotation:-45,margin:{top:5}},title:{fontSize:'90%'}}}};var mychart=new Y.Chart({dataProvider:myDataValues,interactionType:'planar',render:'#mychart',categoryKey:'Date',styles:styleDef,categoryType:'time',horizontalGridlines:{styles:{line:{color:'#fff'}}},verticalGridlines:{styles:{line:{color:'#fff'}}}})});&lt;br /&gt;&lt;br /&gt;"];
var simpleHead = [scriptHead];
var simpleTail = [scriptTail];
var oldData = JSON.parse(result, revive);
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;
&lt;script language="JavaScript" type="text/javascript"&gt;
    // variable? or something here? 

    for(i=0; i&lt;oldData.results.bindings.length ;i++)
    {
        document.write(simpleHead[0] + '&lt;br /&gt;{Date: "' + oldData.results.bindings[i].date + '", Liability: ' + oldData.results.bindings[i].liability + ", Stock: " + oldData.results.bindings[i].stock + ", " + oldData.results.bindings[i].event + ": " + oldData.results.bindings[i].current + ",}" + simpleTail[0] + "&lt;br /&gt;&lt;br /&gt;");
    }
&lt;/script&gt;
&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
