[thelist] dHtml <td> contents

dave gray dascott at wam.umd.edu
Wed Nov 15 23:10:19 CST 2000


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


On Wed, 15 Nov 2000, Tab Alleman wrote:

> Ok, I'm going in that direction, and it looks pretty good for a while, but
> now I've run into this:  I need to send the id of <td> to the javascript
> function (cuz I lied:  I don't really just have 2 <td>'s.)
> 
> So I've got something like this in my select's onchange:
> onchange=UpdateTD(this,'TV1')
> 
> 	function UpdateTD(eType,eCt)
> 		{
> 		alert(eType.selectedIndex + ', ' + eCt);
> 		if (eType.selectedIndex == 0)
> 			{
> 			document.all.eCt.innerHTML = '<%= tdText %>';
> 			}
> 		}
> 
> and my function looks like this (at the moment):
> 
> What happens when I select the first element and trigger the onchange, the
> alert works as expected: "0, TV1"
> But next I get an error that "document.all.eCt is not an Object"..
> 
> erm.. how do I get it to interpret eCt as the value I passed it, and not
> literally "eCt"?
> 
> I love JavaScript.  :)
> 
> -----Original Message-----
> Probably the technique you want to look at is assigning the desitination
> cell (the cell into which you wish to load the content) an id, then set the
> innerHTML of that cell through the DOM.
> 
> For example:
> 
> <table>
>   <tr>
>     <td id=foo>bar</td>
>   </tr>
> </table>
> 
> Then, somewhere in javascript, execute:
> 
>   document.all.foo.innerHTML = 'bar2';
> 
> 
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt ! 
> 





More information about the thelist mailing list