Hi, Have you deal with this 'eval' function issue ? In the JS code below - option a) work well but the b) is not working. Have you any idea why? It's this a JS bug ? I need this for having a line like: eval('document.all.counter_' + param1 + '.innerHTML') = 123; Thanks, Dorin //--------JS script---------- function test() { html_code = '<div id="mydiv"></div>'; document.write(html_code); // -- a) document.all.mydiv.innerHTML = 123; // -- b) eval('document.all.mydiv.innerHTML') = 123; }
eval('document.all.mydiv.innerHTML') = 123; Code (markup): This doesn't work because document.all.mydiv.innerHTML is a pointer to the innerHTML property of the mydiv object. When you call eval('document.all.mydiv.innerHTML'), you get back the CONTENTS of the mydiv, returned as a string. The value returned is literally the string 'whatever html here'. When you try to set THAT STRING equal to something else, you are trying to change the string only, at that point it has no idea that it WAS the innerHTML of a div, all it knows is it is a string. But you can do it like this: eval('document.all.mydiv').innerHTML = 123; Code (markup):