title: Use Iframe to embed csv and allow user to search from it
body: <p>I have a simple html/jscript code here which allow users to enter a keyword and return result from sample csv data (simulated as var CSV in this code) to table format in HTML, now I wish to use the iframe where the CSV is embedded instead of referring my DB to this simulated CSV, how can I do that?
  This code is working fine but I need to refer my search database to iframe.
  Thank you in advance.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;CSV Database&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
          /* Following is a SIMULATED CSV file only.*/
          var CSV =  'APRIL,RED,HAPPY,TEACHER,092236015\n';
          CSV += 'BRIAN,YELLOW,SAD,ENGINEER,092236015\n';
          CSV += 'JIMBOY,BLUE,CRAZY,PROGRAMMER,092236015\n';
          CSV += 'JAYCEE,GREEN,MOODY,MAKE-UP_ARTIST,092236015\n';
          CSV += 'GALLIE,BLACK,SERIOUS,CYCLIST,092236015\n';
      &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body onload="MakeDB()"&gt;
      Keyword: &lt;input type="text" value="" id="ERP"&gt;
      &lt;input type="button" value="Search"   onclick="CSVsearch(document.getElementById('ERP').value)"&gt;
      &lt;p&gt;
      &lt;div id="tblDisplay"&gt;&lt;/div&gt;
      &lt;script type="text/javascript"&gt;
  
          var DB = new Array();
          function MakeDB() { DB = CSV.split('\n'); }
  
          function CSVsearch(dbInfo) {
              var posn = -1;
              for (i=0; i&lt;DB.length; i++) {
                  tmp = DB[i];
                  if (tmp.indexOf(dbInfo) != -1) { posn = i; break; } 
              }
              if (posn == -1) { alert('No matching result from the file'); }
              else { document.getElementById('tblDisplay').innerHTML =    displayAsTable(DB[posn]); }
          }
  
          function displayAsTable(info) {
              var str = '&lt;table border="1" width="35%"&gt;';
              var ary = info.split(',');
              str += '&lt;tr&gt;&lt;th&gt;KEYWORD&lt;/th&gt;&lt;th&gt;INFO1&lt;/th&gt;&lt;th&gt;INFO2&lt;/th&gt;&lt;th&gt;INFO3&lt;/th&gt;&lt;th&gt;INFO4&lt;/th&gt;&lt;/tr&gt;';
              str += '&lt;tr&gt;&lt;td&gt;'+ary.join('&lt;/td&gt;&lt;td&gt;')+'&lt;/td&gt;&lt;/tr&gt;';
              str += '&lt;/table&gt;';
              return str;
          }
      &lt;/script&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;br&gt;
      &lt;iframe src="file:///C:/Users/april_ibanga/Desktop/data.txt" name="data" frameborder="1" scrolling="auto" width="700" height="300" align="bottom"&gt;&lt;/iframe&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>