[thelist] innerHTML and DOM [solved]

.jeff jeff at members.evolt.org
Mon Sep 16 13:25:00 CDT 2002


tom,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Tom Dell'Aringa
>
> ahh..if I had only tried this first. For those
> interested:
>
> cell.innerHTML = "<input type=\"checkbox\" id=\"box1\"
> /><label for=\"box1\">checkbox</label>";
> row.appendChild(cell)
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

or, you could have simply created a checkbox and label elements and appended them to the cell which you then appended to the row (not tested).

checkbox = document.createElement('INPUT');
checkbox.type = 'checkbox';
checkbox.id = 'box1';
label = document.createElement('LABEL');
label.htmlFor = 'box1';
label.innerText = 'checkbox';
cell.appendChild(checkbox);
cell.appendChild(label);
row.appendChild(cell);

fwiw, using innerHTML is the very reason why i've stopped using double-quotes as string qualifies in javascript.  i get tired of having to escape all the double-quotes around attribute values.  so, i just use single-quotes instead.  saves me time, is easier to debug, and much easier to read.

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list