I describe my problem with following simple example.
here when i click the test button it will create a new test button inside div tag.
But after that if i clicked new generated test button document.getElementById("test" ).onclick = function() is not working.
how can i add functions to new dynamically created fields?
Can anyone help me?
<div id="a" >
</div>
<input type="button" value="Test" id="test" class="form-submit"/>
<script language="JavaScript" type="text/javascript" >
document.getElementById("test" ).onclick = function(){
document.getElementById("a").innerHTML="<input type='button' value='Test' id='test' name='test' class='form-submit' />";
alert("test is clicked");
}
</script>