Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

firstly thank you for the reply i am giving the details below kindly check and advice

i am trying to add dynamic rows(html,using javascript) using the below code(for this in html i have created one row with the same fields and once user clicks add button i am calling this function) it works and i am able to create rows dynamically and also able to insert the data into the database(using IE only)(using JSP) but with any other browser i am able to add rows dynamically(in mozilla,chrome) but when i am saving data it is taking the first record only and not the remaining values
JavaScript
function addRow(tableID) {
     var table = document.getElementById(tableID);
      var rowCount = table.rows.length;   
      var row = table.insertRow(rowCount);
      var colCount = table.rows[0].cells.length;
       for(var i=0; i<colCount; i++) {
       var newcell = row.insertCell(i);
     newcell.innerHTML = table.rows[0].cells[i].innerHTML;
         switch(newcell.childNodes[0].type) {
        case "select-one"         
        newcell.childNodes[0].selectedIndex = 0;        
        break;
        case "text"         
        newcell.childNodes[0].value = ""        
         break;
        case "select-one"         
        newcell.childNodes[0].selectedIndex = 0;       
         break;
        case "select-one"
         {
        newcell.childNodes[0].selectedIndex = 0;        
         }
        break;
        case "text":
        newcell.childNodes[0].value = ""       
         break;
         }
             }
             }
Posted
Updated 2-Nov-17 22:25pm
v5
Comments
AshishChaudha 30-Jun-12 4:17am    
what you had done so far...??..we cant see you screen..or read your mind to give you advice for your problem..
Sandeep Mewara 30-Jun-12 6:25am    
Until you share what is working in IE and not in other browsers, how will anyone help?
mahesh_npr 2-Jul-12 2:59am    
hi,
Sandeep Mewara
firstly thank you for the reply i am giving the details below kindly check and advice

i am trying to add dynamic rows(html,using javascript) using the below code(for this in html i have created one row with the same fields and once user clicks add button i am calling this function) it works and i am able to create rows dynamically and also able to insert the data into the database(using IE only)(using JSP) but with any other browser i am able to add rows dynamically(in mozilla,chrome) but when i am saving data it is taking the first record only and not the remaining values


function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i

1 solution

Please refer:
Dynamically add and remove rows in an HTML table[^]
Dynamically Add/Remove rows in HTML table using JavaScript[^]
Here you will get some code for reference to dynamically add and remove rows in an HTML table using JavaScript.

How to insert data into databse by JSP form[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900