Javascript event after all controls posted to the page?-Collection of common programming errors
I have created a javascript that checks if the grid have no rows it will insert a cell with input button in it, the problem is that when i try to fetch the grid by document.getElementByID() the value returned is null because the controls is not yet loaded to the page. So is there an event that would interact with controls cause i don’t want to invoke it from the page, i would like this to be automatically ?
Edit: I have tried window.onload and it didn’t work, the wierd thing is that when i traced it, the page load runs first and the grid gets populate then the javascript function fires.
Here is the code:
window.onload = gridAddButton();
function gridAddButton() {
var gridTable = document.getElementById('');
gridTableRowsLength = gridTable.rows.length;
if (gridTableRowsLength == 0) {
var addButton = document.createElement('input');
addButton.id = 'tempButtonAdd';
gridTable.rows[1].cells[4].appendChild(addButton);
}
}
Edit
Delete