function _dimension(rows){
var arr = [];
for (var i=0;i<rows;i++) {
arr[i] = [];
}
return arr;
}
var arr = _dimension(50);
var _VALUES="field1,field2,field3,field4"
var _BodyValue="field5,field6,field7"
function ajax(){
$.ajax({
type: "GET",
url: "fileName.java",
dataType: "xml",
data: { Sql: SQL}, //xml success: function(data) {if (data.getElementsByTagName("Code")[0]) //Code { NumberOfLine=data.getElementsByTagName('Code').length; _b = _VALUES.split(','); _gentable("td_id",_b.length+1,NumberOfLine);
for (rr=0; rr<NumberOfLine;rr++)
{
for (a=0;a<_b.length;a++){
_1=_b[a];
_value=data.getElementsByTagName(_1)[rr].childNodes[0].nodeValue
_refresh("td_id"+"["+(rr+1)+"]"+"["+(a+1)+"]",_value);
}
}
if (_BodyValue){_p1=_VALUES+","+_BodyValue;} else {_p1=_VALUES;}
_b = _p1.split(',');
for (rr=0; rr<NumberOfLine;rr++)
{ var _2="";
var delimiter="";
for (a=0;a<_b.length;a++){
_1=_b[a];
_value=data.getElementsByTagName(_1)[rr].childNodes[0].nodeValue
_2=_2+delimiter+_value;
delimiter=",";
}
arr[rr+1]=_2;
}
_a=arr[1];
var _b = _a.split(',');
for (i in _b){ _refresh("tb_body"+"["+(i*1+1)+"]"+"["+1+"]",_b[i]); }
$("#td_id tr").not(':first').hover(function () {
// $('#td_id tr').not(':first').on('click hover', function () {
var RowIndex = $(this).index();
_refreshv('rowno',RowIndex);
_a=arr[RowIndex];
var _b = _a.split(',');
for (i in _b){
_refresh("tb_body"+"["+(i*1+1)+"]"+"["+1+"]",_b[i]);
}
$(this).css("background","yellow");
},
function () {$(this).css("background","");
});} } })}
function _gentable(tableName,ColNos,RowNos,_Align){ if (_Align==null){_Align="center";} var ThisTable=document.getElementById(tableName); while(1){ var lastRow = ThisTable.rows.length; if (lastRow >=2) ThisTable.deleteRow(lastRow - 1);else break; } for (var RowNo=1;RowNo<=RowNos;RowNo++) { var ThisRow=ThisTable.insertRow(RowNo); for (var ColumnNo=0;ColumnNo<ColNos;ColumnNo++) { var ThisCell=ThisRow.insertCell(ColumnNo); ThisCell.id=tableName+"["+RowNo+"]"+"["+ColumnNo+"]"; ThisCell.align=_Align; if(ColumnNo==0){ThisCell.innerHTML=RowNo;} } } }
沒有留言:
張貼留言