I have this javascript function:
function addItem(tableID){
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement("input");
element1.type = "checkbox";
element1.name="checkbox[]";
cell1.appendChild(element1);
var cell2 = row.insertCell(1);
var element2 = document.createElement("input");
element2.type = "text";
element2.name = "textbox[]";
cell2.appendChild(element2);
var cell3 = row.insertCell(2);
var element3 = document.createElement("input");
// *****I DO NOT KNOW WHAT GOES HERE*****
cell3.appendChild(element3);
}
I also have an HTML file that where it looks like this:
<header>
<div id="header-left">
<input type="checkbox" id="select-all"></input>
<label for="select-all" id="select-all-tag"> Select All </label>
</div>
<h1> TODO </h1>
<div id="header-right">
<button id="sort-by">Sort By</button>
<button id="add-new" onclick="addItem('todoTable')">Add</button>
</div>
</header>
<table id="todoTable" border="1">
<tr>
<td><input type="checkbox" name="checkbox"/></td>
<td><input type="text" /></td>
<script>
$(function() {
$(".date-picker").datepicker();
});
</script>
<td><input type="text" name="date[]" class="date-picker datepicker"></td>
</tr>
</table>
The HTML file creates the sort of row that I want. For the JavaScript, I am trying to add a row with a datepicker in the third cell, but I do not know how. So, how do I have a datepicker show in the third cell in JavaScript? Please let me know if you need clarification.