I am trying to call a js function on blur effect of dynamically created textbox. Code are as follows.
js to add dynamic text box
JS Function to be called on blur effect of above dynamically created element.
js to add dynamic text box
Code:
{ var el3 = document.createElement('input'); el3.type = 'text'; el3.name = 'children' + i; el3.id = 'children' + i; //el3.setAttribute('onblur',"myFunction()"); el3.onblur = function(){myFunction();}; thirdCell.appendChild(el3); frm.h.value=i; i++; }
Code:
function myFunction() { var x = document.getElementById("child1").value; for(i=0;i<x;i++) { var childAge = prompt("Enter Child " + (i+1) + " age") childageDetail.push(childAge); } //Loop for child age display for(ageDisplay = 1; ageDisplay < childageDetail.length; ageDisplay++) { alert("Child "+ ageDisplay +" age "+ childageDetail[ageDisplay]); } }
Comment