[thelist] appendChild() exception

joe stowaway at uklinux.net
Thu Oct 23 02:32:17 CDT 2003


Hassan Schroeder wrote:

>
>> but I can't find anywhere that lists exactly what exactly nodes do 
>> not allow children or whether form controls are such nodes.  
>
>
> There's nodes and there's nodes :-)
>
> A node can be one of types TAG, ATTRIBUTE or TEXT.
>
> So you can append an *attribute* to something like a checkbox, but
> not append another tag, because <input/> is an *empty* tag -- can't
> contain other elements.
>
> You could add a tag node to the parent of the checkbox, though.
>
> HTH!

hey thanks Hassan, yeah it does help, but I'm getting a little 
worried...  I'm trying to append or replace a text node:

<code>
<input type="checkbox" "id="qsfcontrol" onClick="toggle(this)" />Tick 
the box to ignore these search criteria
</code>

if I understand you correctly, the text "Tick the box to ignore these 
search criteria" is not a child of 'qsfcontrol' which would explain why 
when I originally tried replaceChild(), nothing at all happened, no 
errors, nothing.  Is it then a sibling?

checking the box disables part of the form (nice idea I got from Nelson 
in an earlier thread) and I want to toggle the text next to the box. 
 the form isn't in a table, so the box and the text aren't separable by 
<td>, so I'm wondering what is the semantically correct way to structure 
the message next to the text box.

Of course I could put the text in a named <p>, <span>, <li> etc, and use 
replaceChild() on that text node but then I have to assign a special 
class to it which I want to avoid. Its going to be part of a very large 
site, and I want my CSS to stick with type selectors as much as 
possible, rather than having a ton of classes all over the place as well.

joe




More information about the thelist mailing list