Hi,
I am very new to JS. Do not know how to do this.
Have dynamic table with 4 columns. User can add rows - 7 max - and insert data into each cell. First 2 cells use JQuery for calendar - start & end dates. Third cell is select list with 4 values. Fourth cell user inputs number - integer/decimal, like 1.25 or 2.75. Want to be able to update SQL Server db table with user entries. Figure first that the number of added rows - 1, 2, 3...7 - must be recognized then data from each cell in each row must be read then posted. How do I do this?
Code for dynamic table follows:
<script language="Javascript" type="text/javascript">
function addRow()
{
var tbl = document.getElementById('ReqDtTbl');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
var cellLeft = row.insertCell(0);
var textNode = document.createElement('input');
textNode.size = 7;
textNode.name = 'startdate' + iteration;
cellLeft.appendChild(textNode);
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'enddate' + iteration;
el.id = 'enddate' + iteration;
el.size = 7;
cellRight.appendChild(el);
// the last cell!
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'TypeHrs' + iteration;
sel.options[0] = new Option('-Select-', '""');
sel.options[1] = new Option('Comp Time', 'Comp Time');
sel.options[2] = new Option('Credit Hrs', 'Credit Hrs');
sel.options[3] = new Option('Overtime', 'Overtime');
sel.options[4] = new Option('Rel Comp', 'Rel Comp');
cellRightSel.appendChild(sel);
var cellRight = row.insertCell(3);
var el = document.createElement('input');
el.type = 'text';
el.name = 'No. of Hours' + iteration;
el.id = 'No. of Hours' + iteration;
el.size = 7;
cellRight.appendChild(el);
}
Appreciate any effective help. Thanks, John
I am very new to JS. Do not know how to do this.
Have dynamic table with 4 columns. User can add rows - 7 max - and insert data into each cell. First 2 cells use JQuery for calendar - start & end dates. Third cell is select list with 4 values. Fourth cell user inputs number - integer/decimal, like 1.25 or 2.75. Want to be able to update SQL Server db table with user entries. Figure first that the number of added rows - 1, 2, 3...7 - must be recognized then data from each cell in each row must be read then posted. How do I do this?
Code for dynamic table follows:
<script language="Javascript" type="text/javascript">
function addRow()
{
var tbl = document.getElementById('ReqDtTbl');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
var cellLeft = row.insertCell(0);
var textNode = document.createElement('input');
textNode.size = 7;
textNode.name = 'startdate' + iteration;
cellLeft.appendChild(textNode);
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'enddate' + iteration;
el.id = 'enddate' + iteration;
el.size = 7;
cellRight.appendChild(el);
// the last cell!
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'TypeHrs' + iteration;
sel.options[0] = new Option('-Select-', '""');
sel.options[1] = new Option('Comp Time', 'Comp Time');
sel.options[2] = new Option('Credit Hrs', 'Credit Hrs');
sel.options[3] = new Option('Overtime', 'Overtime');
sel.options[4] = new Option('Rel Comp', 'Rel Comp');
cellRightSel.appendChild(sel);
var cellRight = row.insertCell(3);
var el = document.createElement('input');
el.type = 'text';
el.name = 'No. of Hours' + iteration;
el.id = 'No. of Hours' + iteration;
el.size = 7;
cellRight.appendChild(el);
}
Appreciate any effective help. Thanks, John