0

我已经生成了一个动态 html 表,它在 html 和 javascript 函数的帮助下获取输入值,现在我想用表中的值绘制一个图表,这些值必须从具有的外部文本文件插入到表中需要借助 javascript 上传到页面,使用 PHPlot 的 php JSON 数组。

如何包含必须上传的文本文件以填充动态生成的 html 表的行和列?或者

如何从文本文件中读取动态 html 表的值?

HTML:

     <table id="contentTable" border="1" >
    <!-- Fill table programmatically -->

   <!-- include the .txt file which is present in the htdocs folder -->
    </table>

Javascript:

      function buildTable(val)
     {
   var myTable =document.getElementById("contentTable");
    var j=val;
var rows = [];
var cells = [];

   while (myTable.hasChildNodes()) {
    myTable.removeChild(myTable.lastChild);
   }


for( var i = 0; i < 1; i++ )
{
    rows[i] = myTable.insertRow(i);
    if(i%3==2)rows[i].addClass("every3rdrow");
    cells[i] = [];

    for( var x = 0; x < j ; x++ )
    {
        cells[i][x] =document.createElement((x==0)?"th":"td");
        cells[i][x].innerHTML = (x==0)?"<input>":"<input>";
        rows[rows.length - 1].appendChild(cells[i][x]);
    }
    }

    }
    buildTable();

我想用 phplot 绘制图形。

4

1 回答 1

0

使用 jQuery get( http://api.jquery.com/jQuery.get/ )

$.get("whatever.txt", null, function(data, status, xhr){
   // append data which is content of whatever.txt
   $("table").append(data); // or whatever you want to do with it
});
于 2013-09-18T18:49:48.230 回答