[thelist] dHtml <td> contents

Joshua OIson joshua at alphashop.net
Wed Nov 15 23:48:41 CST 2000


Dave,

the solution you offered with "eval" works, but in most cases it is possible
(at least with JavaScript) to avoid it's use.  Though "eval" itself is not
truly bad, there are more efficient ways of getting to the information.  The
eval function does not execute as fast as other methods, and also creates
convoluted code, or, as they call it in C, "write only code".  The better
method for handling the DOM calls is to use the object arrays already
assumed with the DOM.  In this case, using the document.all array, in the
form of "document.all[eCt].innerHTML" lends itself to faster code and easier
readibility.

When coding in JavaScript, keep in mind that there are not many times when
using "eval" is the best answer, and VERY VERY few times when using "eval"
is *absolutely* necessary.

-joshua

----- Original Message -----
From: "dave gray" <dascott at wam.umd.edu>
To: <thelist at lists.evolt.org>
Sent: Wednesday, November 15, 2000 9:06 PM
Subject: RE: [thelist] dHtml <td> contents


> you need to do:
>
> function UpdateTD(eType,eCt) {
>   alert(eType.selectedIndex + ', ' + eCt);
>   if (eType.selectedIndex == 0) {
>     var ptr = eval("document.all."+eCt);
>     ptr.innerHTML = '<%= tdText %>';
>   }
> }
>
> to get the function to interpolate the value of your variable eCt into the
> correct object
>
> HTH
>
>  -dave





More information about the thelist mailing list