Vacunita,
I do appreciate your help. And I am sorry to trouble you again but, I am lost.
I know variables must be declared, and arrays rest in memory, but I do not know how or where to place the statements
document.getElementById('No_of_Hours1')
document.getElementById('No_of_Hours2')
document.getElementById('No_of_Hours3')
which are to recognize the rows added with their respective
input boxes and corresponding functionality.
And I also came across a JavaScript key word - this
Would this be a means to achieve my desired outcome?
The functions involved are
For the datepicker:
<script type="text/javascript">
$(function() {
$("#startdate").datepicker();
$("#enddate").datepicker();
$("#RcompStart").datepicker();
$("#RcompEnd").datepicker();
});
</script>
For the numeric validation:[/]
<script type="text/javascript">
function checkQuarters( fld )
{
var val = parseFloat(fld.value);
if ( isNaN(val) || ( val*4 != Math.floor(val*4) ) )
{
alert("Value must be a numeric and a multiple of 0.25");
return false;
}
return true;
}
</script>
The array is thus:
<script language="Javascript" type="text/javascript">
/*<![CDATA[*/
var new_rows=new Array();
var row_count=0;
function addRow()
{
var tbl = document.getElementById('ReqDtTbl');
new_rows[row_count]=new Array();
var lastRow = tbl.rows.length;
var iteration = lastRow;
if (lastRow>4){
alert("Maximum rows is 4. For more entries please
submit another request.");
return;}
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);
new_rows[row_count]['cell']=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;
new_rows[row_count]['cell2']=el;
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);
new_rows[row_count]['cell3']=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);
new_rows[row_count]['cell']=el;
row_count++;
}
function removeRow()
{
// grab element again
var tbl = document.getElementById('ReqDtTbl');
// grab length
var lastRow = tbl.rows.length;
// delete last row if there is more than one row
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
/*]]>*/
</script>
I would think these are variables and are stored in memory until called. How? What is the syntax for these elements?
Again, sorry to trouble you. Just trying to get this working and better understand javascript coding.
Many thanks,
John
P.S. - tried many different approaches, unsuccessfully.
I do appreciate your help. And I am sorry to trouble you again but, I am lost.
I know variables must be declared, and arrays rest in memory, but I do not know how or where to place the statements
document.getElementById('No_of_Hours1')
document.getElementById('No_of_Hours2')
document.getElementById('No_of_Hours3')
which are to recognize the rows added with their respective
input boxes and corresponding functionality.
And I also came across a JavaScript key word - this
Would this be a means to achieve my desired outcome?
The functions involved are
For the datepicker:
<script type="text/javascript">
$(function() {
$("#startdate").datepicker();
$("#enddate").datepicker();
$("#RcompStart").datepicker();
$("#RcompEnd").datepicker();
});
</script>
For the numeric validation:[/]
<script type="text/javascript">
function checkQuarters( fld )
{
var val = parseFloat(fld.value);
if ( isNaN(val) || ( val*4 != Math.floor(val*4) ) )
{
alert("Value must be a numeric and a multiple of 0.25");
return false;
}
return true;
}
</script>
The array is thus:
<script language="Javascript" type="text/javascript">
/*<![CDATA[*/
var new_rows=new Array();
var row_count=0;
function addRow()
{
var tbl = document.getElementById('ReqDtTbl');
new_rows[row_count]=new Array();
var lastRow = tbl.rows.length;
var iteration = lastRow;
if (lastRow>4){
alert("Maximum rows is 4. For more entries please
submit another request.");
return;}
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);
new_rows[row_count]['cell']=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;
new_rows[row_count]['cell2']=el;
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);
new_rows[row_count]['cell3']=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);
new_rows[row_count]['cell']=el;
row_count++;
}
function removeRow()
{
// grab element again
var tbl = document.getElementById('ReqDtTbl');
// grab length
var lastRow = tbl.rows.length;
// delete last row if there is more than one row
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
/*]]>*/
</script>
I would think these are variables and are stored in memory until called. How? What is the syntax for these elements?
Again, sorry to trouble you. Just trying to get this working and better understand javascript coding.
Many thanks,
John
P.S. - tried many different approaches, unsuccessfully.