OnChange event for dynamic textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daitasri
    New Member
    • Feb 2008
    • 18

    OnChange event for dynamic textbox

    Hi
    I m creating a textbox dynamically on click of a button. I want to attach an onChange event for that textbox.I tried using following code but it does not seem to work.Can anyone suggest a better way to solve my problem. The code i am using is as follows:

    [CODE=javascript] var cell1 = row.insertCell( 0);
    var addRowTextNode1 = document.create Element('input' );
    addRowTextNode1 .setAttribute(' type','text','n ame','UI'+iIter ation,'id','UI' +iIteration);
    addRowTextNode1 .onChange=funct ion callChange(){al ert('Hi');};
    cell1.appendChi ld(addRowTextNo de1);[/CODE]

    Thanks
    daitasri
    Last edited by gits; Mar 4 '08, 04:04 PM. Reason: added code tags
  • SharpDeveloper
    New Member
    • Feb 2008
    • 12

    #2
    function CreateBox()
    {

    var addRowTextNode1 = document.create Element('input' );
    addRowTextNode1 .setAttribute(' type','text','n ame');
    var x=document.getE lementById('for m1')

    x.appendChild(a ddRowTextNode1) ;
    myOnChange = new Function("e", "callChange()") ;
    addRowTextNode1 .onchange=myOnC hange ;


    }
    function callChange()
    {alert('Hi');};

    Hope this helps!
    Originally posted by daitasri
    Hi
    I m creating a textbox dynamically on click of a button. I want to attach an onChange event for that textbox.I tried using following code but it does not seem to work.Can anyone suggest a better way to solve my problem. The code i am using is as follows:

    [CODE=javascript] var cell1 = row.insertCell( 0);
    var addRowTextNode1 = document.create Element('input' );
    addRowTextNode1 .setAttribute(' type','text','n ame','UI'+iIter ation,'id','UI' +iIteration);
    addRowTextNode1 .onChange=funct ion callChange(){al ert('Hi');};
    cell1.appendChi ld(addRowTextNo de1);[/CODE]

    Thanks
    daitasri

    Comment

    • rnd me
      Recognized Expert Contributor
      • Jun 2007
      • 427

      #3
      in firefox, you may often find it handy to use

      Code:
       elmTextarea.setAttribute("onchange", "alert('function code goes here')"

      Comment

      Working...