title: Generate a list in javascript and add it to a div in html
body: <p>I have a javascript function which gets some values from ajax. From javascript I add that values to a div whose display is by default none. In my function from ajax i also gets an array of values. My task is to make a list on html inside my div based on the array values.
  Can anyone help me to do this..</p>
  
  <p><strong>Javascript function</strong>:</p>
  
  <pre><code>function showpopup(id)
  {
  var advid=id;
  $.ajax
  ({
      type:"post",
      url:"ajax_getadv.php?function=getadv",
      data:{id:advid},
      cache:false,
      success:function(data){
          var values=data;
          var myarray=values.split("/");
          var name=myarray[0];
          var email=myarray[1];
          var country=myarray[2];
          var web=myarray[3];
          var advid=myarray[4];
          var count=myarray[5];
          var val=myarray[6]
          var mytitle=val.split(",");
          document.getElementById("advname").innerHTML = name;
          document.getElementById("advid").innerHTML = advid;
          document.getElementById("email1").innerHTML = email;
          if(country!="")
          {
              document.getElementById("country").innerHTML = country;
          }
          else
          {
              document.getElementById("country").innerHTML = "Not Available";
          }
          if(web!="")
          {
              document.getElementById("website").innerHTML = web;
          }
          else
          {
              document.getElementById("website").innerHTML = "Not Available";
          }
  var generateHere = document.getElementById("newlist");
             var mycount=mytitle.length;
          alert(mycount);
  
           for( var i =  0 ; i &lt; mycount ; i++)
           {  
              generateHere.innerHTML = '&lt;div class="someclass"&gt;&lt;ul&gt;&lt;li&gt;My Text&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;';
           }
      }   
  });
  
  document.getElementById('box-config-modal1').style.display='block';
  </code></pre>
  
  <p>}</p>
  
  <p>Here <strong>mytitle</strong> is the array which i want to display as list. I've put a for loop to create a list in the div. I have to show <strong>mytitle</strong> rather than My text.</p>
  
  <p><strong>HTML div</strong>:</p>
  
  <pre><code>&lt;!--SHOW MODAL 1--&gt;
  &lt;div id="box-config-modal1" class="modal hide fade in" style="display: none;"&gt;
  &lt;div class="box" id="box-details"&gt;
  &lt;h4 class="box-header round-top"&gt;Details&lt;/h4&gt;
  &lt;div class="box-container-toggle" style="padding-left:20px;padding-right:20px;"&gt;
      &lt;div class="box-content" &gt;
      &lt;form name="popup" id="popup" &gt;
      &lt;fieldset&gt;
          &lt;button class="close" data-dismiss="modal"&gt;&lt;/button&gt;
          &lt;h3&gt;User Details&lt;/h3&gt;
          &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt; &lt;label class="control-label" for="typeahead" style="width:100px;float:left;" &gt;Name &lt;/label&gt;&lt;label id="advname" style="padding-left:150px;"&gt;&lt;/label&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt;&lt;label class="control-label" for="typeahead" style="width:100px;float:left;" &gt;ID &lt;/label&gt;&lt;label id="advid" style="padding-left:150px;"&gt;&lt;/label&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt;&lt;label class="control-label" for="typeahead" style="width:100px;float:left;"&gt;Email &lt;/label&gt;&lt;label id="email1" style="padding-left:150px;"&gt;&lt;/label&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt;&lt;label class="control-label" for="typeahead" style="width:100px;float:left;"&gt;Country &lt;/label&gt;&lt;label  id="country" style="padding-left:150px;"&gt;&lt;/label &gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt;&lt;label class="control-label" for="typeahead" style="width:100px;float:left;"&gt;Website &lt;/label&gt;&lt;label  id="website" style="padding-left:150px;"&gt;&lt;/label &gt;&lt;/div&gt;
          &lt;/div&gt;
  &lt;div class="" id="newlist"&gt;
  &lt;/div&gt;
          &lt;div class="modal-footer"&gt;
              &lt;a href="" onClick="window.close()" class="btn btn-primary" data-dismiss="modal"&gt;Exit&lt;/a&gt;
          &lt;/div&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;  
  &lt;/div&gt;
  </code></pre>
  
  <p><br>
      </p>
  
  <p>It is in this div i want to create a list. I've added a new <strong>div with id newlist</strong></p>