OK,
So it's been a while, but I've been really busy. So, I think I've got some of this Ajax stuff figured out, but I'm really stumpped right now, so I thought I would post this before I pull my hair out. Basically, I'm trying to disable a div element with a bunch of stuff in it after getting a sucessful ajax response. It seems to work if I write it like this:
But, you see my problem is having to pass a variable ID to the element, so I need a:Code:var id = o.responseText; if (document.getElementById('1').hasChildNodes()) { while ( document.getElementById('1').childNodes.length >= 1 ) { document.getElementById('1').removeChild( document.getElementById('1')s.firstChild ); } }
... to pass the id back from the response. Now, simple, right? But when I write this code, nothing works:Code:var div = "document.getElementById("+id+")";
The error in firebug says that div.hasChildNodes() is not a function! Why isn't the string being passed????? AHGRRRHH!!!Code:var id = o.responseText; var div = "document.getElementById("+id+")"; if (div.hasChildNodes()) { while ( div.childNodes.length >= 1 ) { div.removeChild(div.firstChild ); } }
Hacking away...


LinkBack URL
About LinkBacks
Reply With Quote