Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic fields on click of button

    This code is working fine on IE but not on firefox
    tryed a lots but not got any solution plz help me out with a solution plzzzzzzzzzzzzz
    the below is the code
    Code:
    var rownumber=1;
        function addRowCards(tbname,countrow){
            //so that user can only add 3 rows
            if(rownumber<=4){   
             var textbox10 = '<select name="payment[]" id="payment[]" style="width:120px;"><option value="M A D">M A D</option><option value="Full Payment">Full Payment</option></select>';//for text box
    		var textbox20 = '<input type="text" name="name" id="name" style="width:60px;" maxlength="30" >';
    		
            var tbname = document.getElementById(tbname);//to identify the table in which the row will get insert
            var rowIndex = document.getElementById(countrow).value;//to identify the row after which the row will be inserted
            try {
                var newRowCards = tbname.insertRow(rownumber);//creation of new row
                //var newCell = newRow.insertCell(0);//first  cell in the row
                //newCell.innerHTML = text;//insertion of the 'text' variable in first cell
                var newCell = newRowCards.insertCell(0);//second cell in the row
                newCell.innerHTML = "<table width='100&#37;' cellspacing='0' cellpadding='0' border='0'><tr><td width='24%'> " + textbox10 + " </td><td width='17%'> " + textbox20 + "</td></tr></table>";//insertion of the text box and the remove text using their variable
                rownumber++;
            } catch (ex) {
                alert(ex); //if exception occurs
            }
               
        }
        if(rownumber>4)//if the row contain 3 textbox, the add button will disapper
        {
    //       alert("You can add Only 5 Rows");
        document.getElementById("addCards").style.display="none";
        }                       
    }
    Last edited by Kor; 08-07-2008 at 11:30 AM. Reason: wrap the code [code][/code]

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    innerHTML is not a standard DOM method. In some cases, for some browsers, innerHTML does not really insert the new elements as belonging to the DOM tree, or even it does not insert the elements at all.

    You should use DOM methods (createElement, appendChild, maybe cloneNode() ... etc) to create/copy/append new elements and their attributes, especially when you are dealing with tables and tables' elements.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kor View Post
    innerHTML is not a standard DOM method. In some cases, for some browsers, innerHTML does not really insert the new elements as belonging to the DOM tree, or even it does not insert the elements at all.

    You should use DOM methods (createElement, appendChild, maybe cloneNode() ... etc) to create/copy/append new elements and their attributes, especially when you are dealing with tables and tables' elements.
    dear it is creating the form but is not capturing the data which i need to insert in the database

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Quote Originally Posted by askupendra View Post
    dear it is creating the form but is not capturing the data which i need to insert in the database
    Quote Originally Posted by Kor
    innerHTML is not a standard DOM method. In some cases, for some browsers, innerHTML does not really insert the new elements as belonging to the DOM tree, or even it does not insert the elements at all.
    Already answered!
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •