Re: "Undefined" in scrolling_list
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: "Undefined" in scrolling_list

From: Thomas 'PointedEars' Lahn <PointedEars@web.de>
Date: Mon Jan 23 2006 - 16:08:47 CET

William wrote:

> I tried to update a scrolling_list with the following:
>
> function saveText( scroll_list, t_area, listToBeUpdated ) {
> var updated = new Option();
> updated.value = t_area.value;
> updated.text = t_area.text;
> scroll_list.options[scroll_list.selectedIndex] = updated;
> }
>
> but I get "Undefined" in the position with the new Option()
> (i.e. "updated").
>
> Why

Because you try to overwrite a reference to a DOM object with a
reference to another DOM object, which is not always possible.

> and how to fix this?

  function saveText(scroll_list, t_area, listToBeUpdated)
  {
    var updated = scroll_list.options[scroll_list.selectedIndex];
    updated.value = t_area.value;
    updated.text = t_area.text;
  }

PointedEars
Received on Tue Feb 7 21:19:14 2006