...

View Full Version : Dynamic fields on click of button



askupendra
08-07-2008, 11:42 AM
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


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";
}
}

Kor
08-07-2008, 12:35 PM
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.

askupendra
08-09-2008, 08:49 AM
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

abduraooft
08-09-2008, 06:12 PM
dear it is creating the form but is not capturing the data which i need to insert in the database

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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum