Link to home
Start Free TrialLog in
Avatar of pankajrathod84
pankajrathod84

asked on

Set Attribute Not working with IE

HI Here is my code

Here appending Element to div
                  $("#txtBtn").click(function(event){
                        var txtBox=getTextbox("txt"+ txtCount );
                        txtCount ++;
                         $("#testDiv").append(getLineItem(txtCount));
                        });
  #########################CREATING ELEMENT#################################

                  function getLineItem(number) {
                        var div = document.createElement('div');
                        //Give the div a unique id
                  
                        div.setAttribute('id','lineitem_' + number);
                  
                        //pass unique values to the getTextbox() function
                        var t1 = getTextbox('txt_' + number + '_1');      
                        var r1 = getRadio('rdoEmail');      
                        var b1 = getDelButton('btn_'+ number,number);                              
                        div.appendChild(t1);                                          
                        div.appendChild(r1);      
                        div.appendChild(b1);                                          
                        return div;
                  }

                  function getTextbox(id) {
                        var textbox = document.createElement('input');
                        textbox.setAttribute('id',id);
                        textbox.setAttribute('name',id);
                        return textbox;
                  }
                  
                  function getRadio(id) {
                  
                        var radio = document.createElement('input');                  
                        radio.setAttribute('type',"radio");
                        radio.setAttribute('id',id);
                        radio.setAttribute('name',id);
                        return radio;
                  }
                  
                  function getDelButton(id,number) {                  
                        var btn = document.createElement('input');                  
                        btn.setAttribute('type',"button");
                        btn.setAttribute('value',"Remove");                        
                        btn.setAttribute('id',id);
                        btn.setAttribute('name',id);
                        var divID='lineitem_' + number;
                        //btn.setAttribute('OnClick','removeEmail('+ divID +');');
                        btn.setAttribute.OnClick=removeEmail(divID);
                        return btn;
                  }
                  
                  function removeEmail(id)
                  {                              
                        alert(id);
                        var divMail=document.getElementById('testDiv');
                        divMail.removeChild(id);                        
                     $(id).hide();

                                          
                  }
                  

I am able to append the element on button Click. while appending I am creating a button to remove the row. It is working fine  in firefox but not in IE.

Please help. Also tell me if there is any alternative method to append and delete element dynamically in the form using JQuery or javascript
ASKER CERTIFIED SOLUTION
Avatar of araim
araim
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial