[Javascript] need guidance to transfer info from one table to another

Nick Fitzsimons nick at nickfitz.co.uk
Sat Apr 7 10:43:38 CDT 2007


On 7 Apr 2007, at 15:12:40, DeWayne Crenshaw wrote:

> I only want to transfer the text (not the
> text-box.) I tried to adapt innerHTML, but am having
> trouble doing so. What am I doing wrong?:
>
> // cell 1 - input text
> document.getElementById("Table1");
> var el = document.getElementById("textBox").innerHTML;
> var cell1 = row.insertCell(1).textBox(el);
>
> any assistance would be appreciated...

A text input doesn't have any innerHTML: it's an empty element. The  
text typed in is held in its value property, and need to be converted  
into a text node to append to the cell. So:

var value = document.getElementById("textBox").value;
var cell1 = row.insertCell(1);
cell1.appendChild(document.createTextNode(value));

should do what you want.

HTH,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/






More information about the Javascript mailing list