Sending data to the servlet is also a easy process....
Say in each row say there are 3 cells....and each cell u have textboxes....
Using the code in the site I posted last time u can dynamiccaly assign the name to the text boxes.....say for row no 3 the 3 text boxes name are txt31 , txt32 and txt33.
Now at the end of the loop we have to keep the max value of row and clumn...ie. 3 and 3 in this case and get the parameters in the servlet using a for loop.....
If the above seems confusing ...post the code u have developed using the link posted by me....I will help u out...
Thanks,
In my servlet i have this code to test if i can catch the values but it just read the first row which is a row added by default in my jsp so when i show my jsp the table has 1 row and i start to add more rows from that one.
int n=1;
boolean flag=true;
System.out.println("Entr?por el bot髇 registrar");
while (flag){
String nameForm = request.getParameter("txtRow" + n + 1);
if(nameForm==null){
System.out.println("Hay un total de: " + (n-1) + " de filas");
break;
}
String tipoDocForm = request.getParameter("txtRow" + n + 2);
String nroDocForm = request.getParameter("txtRow" + n + 3);
System.out.println(nameForm);
System.out.println(tipoDocForm);
System.out.println(nroDocForm);
n++;
}
my js
function addRowToTable() {
var tbl = document.getElementById('tableVisitantes');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// nro cell
var nroCell = row.insertCell(0);
var textNode = document.createTextNode(iteration);
nroCell.appendChild(textNode);
// nombre cell
var nombreCell = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration + '1';
el.id = 'txtRow' + iteration + '1';
el.size = 20;
nombreCell.appendChild(el);
// tipo doc cell
var tipoDocCell = row.insertCell(2);
var sel = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration + '2' ;
el.id = 'txtRow' + iteration + '2';
el.size = 20;
tipoDocCell.appendChild(sel);
// nro doc cell
var nroDocCell = row.insertCell(3);
var sel = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration + '3';
el.id = 'txtRow' + iteration + '3';
el.size = 20;
nroDocCell.appendChild(sel);
}
function removeRowFromTable() {
var tbl = document.getElementById('tableVisitantes');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}