Ron Brennan wrote:
"RobG" <rg***@iinet.ne t.auau> wrote in message
[...]
Much appreciated Rob - thanks; My immediate problem turned out to be the
additional child was being created by a carriage return being generated by
the second println (I wrongly thought the servlet part to be irrelevant):
out.println("<t d></td><td id='fileList'>" );
out.println("<i nput type=\"hidden\" name=\"file\" id=\"file_0\"
value=\"Test Name\"/>");
out.println("</td>");
I've been working on this for days and found it within 5 minutes after
posting. Rob's information is something I didn't know and copied.
The bottom line is that you need to be aware that different browsers
collapse whitespace differently. Any navigation you do up or down the
DOM tree should use a method that is independent of the number of
intervening nodes and not just assume that there are /x/ nodes between
here and there.
In the example you posted, getting to the first input from the span
could be:
// use getElementsByTa gName
function getFirstChildIn put( spanId ) {
if ( !docment.getEle mentById || !document.getEl ementsByTagName ) {
return null;
}
var x=document.getE lementById(span Id).getElements ByTagName('inpu t')
return ( x.length > 0 )? x[0] : null;
}
// walk down tree
function getFirstChildIn put( spanId ) {
if ( !docment.getEle mentById ){return null}
var x = document.getEle mentById(spanId ).childNodes;
var i = x.length;
while ( i-- ) {
if ( 'input' == x[i].nodeName.toLow erCase() ) {
return x[i];
}
}
return null; // or whatever if an input isn't found
}
--
Rob