WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Prototype Object Properties, Lister Storm, May 9, 2005
     Re:Prototype Object Properties, TY Kuo, May 13, 2005
         Re:Prototype Object Properties, Erik Arvidsson, May 22, 2005

Subject: Prototype Object Properties From: Lister Storm Date: May 9, 2005

Hi, I am new to protoype programming in Javascript and I need a little help if you would.  I have the following code, but I am having a little difficultly adding the items in my FOR loop to my objects LIST object (see code below).

function MySelectList(id) {

MySelectList.prototype.init = function(root) {
  this.root = root;
  this.list = new Array();
  this.elements = root.getElementsByTagName("li");
  for (var i=0; i < this.elements.length; i++) {
    this.elements[i].onclick = function() {
      this.className = 'hilight';
      this.list[this.list.length] = this;

I can understand that once I'm into the ONCLICK event that this is no longer the MySelectList object, and hence the line this.list[this.list.length] = this; makes no sence as the LI element doesn't have a this.list object defined.  So my question, is how can I add the current LI element found to the list defined in the lines above?

Any help is greatly appreciated, thanks Lister


Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.

View All Messages
Back to WebFX