我的代码:
function addRows(tableID, Fecha,CallerId,Documento,Agente,NombreEncuesta,Pregunta,Respuesta) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
//var row = document.createElement('tr');
var cell1 = row.insertCell(0);
cell1.innerHTML = Fecha.Value;
var fechaValue = Fecha.Value;
var fechaFormato = fechaValue.formatDate("yyyy-MM-dd HH:mm");
var cell2 = row.insertCell(1);
cell2.innerHTML = CallerId;
var cell3 = row.insertCell(2);
cell3.innerHTML = Documento;
var cell4 = row.insertCell(3);
cell4.innerHTML = Agente;
var cell5 = row.insertCell(4);
cell5.innerHTML = NombreEncuesta;
var cell6 = row.insertCell(5);
cell6.innerHTML = Pregunta;
var cell7 = row.insertCell(6);
cell7.innerHTML = Respuesta;
table.tBodies[0].appendChild(row);
}
Date.prototype.formatDate = function(format)
{
var date = this;
if (!format)
format="MM/dd/yyyy";
var month = date.getMonth() + 1;
var year = date.getFullYear();
format = format.replace("MM",month.toString().padL(2,"0"));
if (format.indexOf("yyyy") > -1)
format = format.replace("yyyy",year.toString());
else if (format.indexOf("yy") > -1)
format = format.replace("yy",year.toString().substr(2,2));
format = format.replace("dd",date.getDate().toString().padL(2,"0"));
var hours = date.getHours();
if (format.indexOf("t") > -1)
{
if (hours > 11)
format = format.replace("t","pm")
else
format = format.replace("t","am")
}
if (format.indexOf("HH") > -1)
format = format.replace("HH",hours.toString().padL(2,"0"));
if (format.indexOf("hh") > -1) {
if (hours > 12) hours - 12;
if (hours == 0) hours = 12;
format = format.replace("hh",hours.toString().padL(2,"0"));
}
if (format.indexOf("mm") > -1)
format = format.replace("mm",date.getMinutes().toString().padL(2,"0"));
if (format.indexOf("ss") > -1)
format = format.replace("ss",date.getSeconds().toString().padL(2,"0"));
return format;
}