这是我尝试过的:
function showTableOfVauchers(data) {
var div = document.getElementById("table");
var str = "<table aligh='left'><tr><th>#</th>"+"<th>VendorID</th><th>Amount</th><th>date</th><th>Invoice#</th><th>Fund</th><th>DeptID</th><th>Description</th></tr>";
for(var i=0; i<data.length; i++)
{
str += "<tr><td>"+data[i].doc._id+
"</td><td>"+data[i].doc.vendorID+
"</td><td>"+data[i].doc.amount+
"</td><td>"+data[i].doc.date+
"</td><td>"+data[i].doc.invoiceNumber+
"</td><td>"+data[i].doc.fund+
"</td><td>"+data[i].doc.deptID+
"</td><td>"+data[i].doc.descript+
"</td><td>"+ dateCheck(data[i].doc.date)+
"</td></tr>"
}
str += "</table>";
div.innerHTML = str;
function dateCheck(date1){
if (date1==today){
return "<input type='checkbox' checked>"
}
else {
return "<input type='checkbox'>"
}
}
}
答案 0 :(得分:0)
谢谢你的语法,
if(date1 = today)
我猜它应该是
if(date1==today)
检查您要返回的字符串。
"<input type=\"checkbox\" checked>";