insertRow but no data after submission

E

edencane

Hi.
I've created a page that dynamically adds rows to a table.
When I submit the page the request parameters of the dynamically
generated rows don't get passed to the server.
What is wrong?
Thanks.
Kind regards.
Luke Baker.

my functions:
--------------------------------------------------\
function removeTableRow() {
var t = document.getElementById('moanFish');
var lastRow = t.rows.length;
if (lastRow > 5) t.deleteRow(lastRow - 2);
}
function insertTableRow() {
var names = new Array();
names[0] = "expenseType";
names[1] = "annualAmount";
names[2] = "supplier";
names[3] = "bankAccount";
names[4] = "bank";
names[5] = "bsb";
names[6] = "accountNumber";
names[7] = "ref";
var cells = new Array();
var lastRow = document.getElementById('moanFish').rows.length;
var tblRow =
document.getElementById('moanFish').insertRow(lastRow-1);

// populate an ass. array of cell objects for a single table row
// then populate the cells with input elements
for (j = 0; j < 8; j++) {
var rowNumber =
(document.getElementById('moanFish').rows.length)-1;
cells["f"+j] = tblRow.insertCell(j);
var element = document.createElement('input');
element.type = 'text';
// element.name = 'expenseRow3_expenseType';
// element.id = 'expenseRow3_expenseType';
element.name = 'expenseRow' + rowNumber + "_" + names[j];
element.id = 'expenseRow' + rowNumber + "_" + names[j];
if (j == 0 || j == 3) { element.size = 16; }
else { element.size = 10; }
cells["f"+j].appendChild(element);
}
alert(document.getElementById('moanFish').innerHTML);
// add the right border to the last cell in the row
cells["f7"].style.borderWidth = "1px 1px 0px 1px";
}
_______________________________________________________/
 
C

Chad.Burggraf

Hi.
I've created a page that dynamically adds rows to a table.
When I submit the page the request parameters of the dynamically
generated rows don't get passed to the server.
What is wrong?
Thanks.
Kind regards.
Luke Baker.

What server-side language are you using?

Cheers
Chad
 
E

edencane

Hi.


What server-side language are you using?
Java. Purely jsp currently.

I've changed the javascript to use innerHTML instead of DOM and it now
works in IE and FF but not Opera9. Hmmmm.

Kind regards.
Luke.
 
C

Chad Burggraf

edencane said:
I've changed the javascript to use innerHTML instead of DOM and it now
works in IE and FF but not Opera9. Hmmmm.

Kind regards.
Luke.

That is odd. Make sure you didn't switch to innerHTML for the actual
row/cell creation. I don't know about IE7, but in IE6 you can't modify
table rows via innerHTML.

The only thing I could think previously was some sort of server-side
event validation, a-la ASP.NET. Unfortunately I'm not sure with JSP.

You could always serialize the final form with Javascript and submit a
GET request (or Ajax POST).

Cheers
Chad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top