It's basically a text input box with a label that when clicked a popup Calendar is displayed which lets the user select a date, which is then returned to the text input box.. This script works fine on the HTML.
I want to create this input box and call the Calendar script from another javascript function using the following code.
Code:
var inp2 = document.createElement('INPUT');
inp2.setAttribute('name','interviewdate'+Table1RowId);
inp2.setAttribute('maxlength','15');
inp2.setAttribute('size','15');
I'm not sure how to code the HTML line above into this script using the createelement function.
I've looked at pasting the code directly into the createElement function but it doesnt work, I've also tried to mess about with InnerHTML.. ie. inp2.InnerHTML("]<input type="Text" name="interviewdate" maxlength="15" size="15" value="<%=intdatein%>"><a href="javascript:NewCal...blahblah")
<head>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
</script>
function addRow_table1()
{
var tbody = document.getElementById('table1').getElementsByTagName('tbody')[0];
var row = document.createElement('TR');
var cell1 = document.createElement('TD');
var cell2 = document.createElement('TD');
var cell3 = document.createElement('TD');
var cell4 = document.createElement('TD');
var cell5 = document.createElement('TD');
var inp1 = document.createElement("<textarea name='awarding' cols='30' rows='5'></textarea>");
//var inp2 = document.createElement("<input type='Text' name='interviewdate' maxlength='15' size='15' value='<%=intdatein%>'><img src='cal.gif' width='16' height='16' border='0' alt='Pick a date'></img>");
var inp2 = document.createElement('INPUT');
var inp3 = document.createElement('INPUT');
var inp4 = document.createElement("<textarea name='recommend' cols='30' rows='5'></textarea>");
var inp5 = document.createElement('INPUT');
inp1.setAttribute('name','awarding'+Table1RowId);
inp2.setAttribute('type','text');
inp2.setAttribute('name','awarddatet'+Table1RowId);
inp2.setAttribute('maxlength','15');
inp2.setAttribute('size','15');
inp3.setAttribute('type','text');
inp3.setAttribute('name','result'+Table1RowId);
inp4.setAttribute('name','recommend'+Table1RowId);
inp5.setAttribute('type','button');
inp5.setAttribute('value','Delete');
inp5.onclick=function(){delRow_table1(this);}
//cell1.innerHTML = gRowId;
cell1.appendChild(inp1);
cell2.appendChild(inp2);
cell3.appendChild(inp3);
cell4.appendChild(inp4);
cell5.appendChild(inp5);
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell4);
row.appendChild(cell5);
tbody.appendChild(row);
Table1RowId++;
}
</script>
</head>
<body>
<table width="78%" border="1" id="table1">
<tbody>
<tr>
<td><div align="center"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Awarding
Body (IIP. SQMS, HMI, SQA, CISCO, Microsoft, EFQM)</font></strong></div></td>
<td><div align="center"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Date</font></strong></div></td>
<td><div align="center"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Result
(if Applicable)</font></strong></div></td>
<td><div align="center"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Recommendations
/ Areas for Improvement (If Applicable)</font></strong></div></td>
<td><div align="center"><strong></strong></div></td>
</tr>
</tbody>
</table>
<input type="button" value="Insert Row" name="b1" onClick="addRow_table1();">
</body>
As you can see from above.. I have a table named TABLE1 with a button "ADD ROW" When clicked, a new row is created dynamically on the table. I want to add the datetime picker javascript in the new row.. in this case variable named INP2. In the code above for INP2 I have commented out the code I entered that I thought would have worked.. but it doesnt..
thanks
That seemed to fix that error, however, there is no where to click to luanch the Datetime picker..? in the html example I posted ,the dtpicker has a calender image (a href) that when clicked opens a new window containing the dtpicker
Bookmarks