我有以下代码:
function test() {
var results = "";
var myArray = [];
myArray[0] = "Thur May 09 2013 00:00:00 GMT+0100 (GMT Daylight Time)";
myArray[1] = "Thur May 10 2013 00:00:00 GMT+0100 (GMT Daylight Time)";
myArray[2] = "Thur May 10 2013 00:00:00 GMT+0100 (GMT Daylight Time)";
myArray[3] = "Thur May 10 2013 00:00:00 GMT+0100 (GMT Daylight Time)";
results = "<table border='1'>";
for (var i = 0; i < myArray.length; i+=2 )
{
results += "<td>Dates</td>";
results += "<td>Price</td>";
results += "<td>Available?</td>";
results += "<tr><td>" + myArray[i+1] + "<tr><td>" + ( myArray[i+1]===undefined ? '' : myArray[i+1] )+ "</tr></td>";
}
results += "<table><br /> <br />";
var div = document.getElementById("associatedAssets");
div.innerHTML = results;
}
test();
我想要以下布局:
Dates | Prices | Available
我希望我的代码填充日期值,但我也希望填充空行,以便用户可以手动输入值。
这是我的 JSFIDDLE:http: //jsfiddle.net/zE2bH/67/