[英]how to read the values of a dynamic html table from a text file?
我已經生成了一個動態html表,它借助於html和javascript函數獲取輸入值,現在我想用表中的值繪制圖形,這些值必須從具有以下內容的外部文本文件插入到表中:可以借助javascript,php JSON數組上傳到頁面上以使用PHPlot。
如何包含一個必須上載以填充動態生成的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繪制圖形。
使用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
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.