Inserting a new row into a table


#1

Am still fairly low on the Rails/Javascript learning curve, so pardon me
if i am missing something elementary–

Am trying to stick a new row at the end of a table in response to some
event.

My table looks like this:

Origin Stops Add

I want to add new row to this table.

My Prototype effort (pun, sort of), was to put in a div right before the
end of the table looking like this:

and to have whatever Javascript run something like this:

new Insertion.Before(‘endOfOriginStops’, ‘

Bite me’);

Didn’t work. (in IE6). Either died quietly or gave some message about
‘invalid target element for this operation’

Ultimately, ended up creating this script

	function ieAppendRow(tableName, rowText) {
		  var tbl = $(tableName);
		  var row = tbl.insertRow();

		  var cell = row.insertCell(0);
		  var textNode = document.createTextNode(rowText);
		  cell.appendChild(textNode);
	}

and calling it like

             ieAppendRow('originStops', 'Bite me');

This works fine in IE6. Doesn’t do diddly in FireFox.

From a few threads I’ve found, I gather IE6 is rather quirky in how in
handles innerHTML, and have seen some illusions to the Prototype library
not handling this correctly. Is this assertion correct? Do I need to
bypass the library for this functionality, or am I missing something?

Thanks
Ed