0
首先,我有一個Google可視化數據表。從表格單元格的輸入字段獲取事件.focusout
之後,我創建了一個for
循環得到表格單元格的值,並把再輸入字段:
for (var y = 0, maxrows = data.getNumberOfRows(); y < maxrows; y++) {
for (var x = 1, maxcols = data.getNumberOfColumns(); x < maxcols; x++) {
data.setValue(y, x, '<input id="costRedovi" vr="'+ data.getValue(y,0) + '" kol="'+ data.getColumnLabel(x) +'" class="form-control" value="'+data.getValue(y,x)+'">');
}
}
現在每個值成表格單元格到輸入字段。現在,我可以在表格準備就緒時更改這些值,但現在如何獲取這些值,因爲我的腳本現在生成此HTML代碼。此外,我需要在輸入欄上獲取有關事件.focusout
值:
<tr class="google-visualization-table-tr-even google-visualization-table-tr-sel">
<td class="google-visualization-table-td"><input id="costRedovi" vr="2013-04-01" kol="John Deer n7" class="form-control" value="0"></td>
<td class="google-visualization-table-td"><input id="costRedovi" vr="2013-04-01" kol="Laza Lazic" class="form-control" value="0"></td>
</tr>
我試着這樣做:
new google.visualization.events.addListener(table, 'ready', function() {
$("#costRedovi").focusout(function() {
console.log($('#costRedovi').attr('value'));
});
});
的問題是,每一個輸入現在具有相同的ID。
ID是唯一,每個輸入不能有相同的ID。 – adeneo
您可以動態創建表格,並且可以像costRedovi + fieldNumber一樣設置您的標識。也請結束你最後一句話。 – Radu
我會嘗試與類... – gmaestro