Friday, March 20, 2009

How To add event to runtime created control -Javascript



<html>
<head>
<title>Untitled</title>
</head>

<body>
<script>
function addRow(){
var table = document.getElementById('table1');
var TR = table1.insertRow();
var TD = TR.insertCell();
TD.innerHTML = 'Row added';
TD.onclick= function(){ alert( 'This is onclick') };
TD.onmouseover= function(){ alert( 'This is mouseover') };

}
</script>

<table id='table1'>

</table>
<br>
<input type='button' value='Add Row' onclick='addRow()'>
</body>
</html>

0 comments:

Your Ad Here