title: Function in For Loop problems
body: <p>I have code to load data from feeds. You can check the jsfiddle <a href="http://jsfiddle.net/HgBVq/" rel="nofollow">here</a>.</p>
  
  <pre><code>&lt;div class="agenda"&gt;&lt;/div&gt;
  &lt;div class="agenda"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  label = ["Tutorials", "Widgets"];
  for (m = 0; m &lt; label.length; m++) {
      function listEvents(json) {
          var feed = json.feed;
          for (var i = 0; i &lt; 10; i++) {
              var entry = json.feed.entry[i];
              var posttitle = entry.title.$t;
  
              //Style
              if (i == 0) {
                  x = "&lt;span style='color:red'&gt;Style 1 + Label 1&lt;/span&gt;&lt;p&gt;" + posttitle + "&lt;/p&gt;";
                  p = "&lt;span style='color:red'&gt;Style 2 + Label 2&lt;/span&gt;&lt;h4&gt;" + posttitle + "&lt;/h4&gt;&lt;p&gt;";
              }
              if (i == 1) {
                  y = "&lt;p&gt;" + posttitle + "&lt;/p&gt;";
                  g = "&lt;h4&gt;" + posttitle + "&lt;/h4&gt;&lt;/p&gt;";
              }
          }
  
          style = [x + y, p + g];
          for (m = 0; m &lt; style.length; m++) {
              document.getElementsByClassName("agenda")[m].innerHTML = style[m];
          }
  
      }
  
      document.write("&lt;script src=\"http://www.allbloggertricks.com/feeds/posts/default/-/" + label[m] + "?orderby=published&amp;alt=json-in-script&amp;callback=listEvents\"&gt;&lt;\/script&gt;");
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I use <code>For</code> loop to load data from <code>2 Labels (Tutorials, Widgets)</code>. </p>
  
  <p>For each Label, I want it uses each style (<code>normal and bold</code> as example in jsfiddle). But I don't know why it load data from only <code>Label</code>. </p>
  
  <p>I need your help. Thanks for all suggestion.</p>