SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Asignment Error

  1. #1
    SitePoint Enthusiast Aquis's Avatar
    Join Date
    Jun 2006
    Location
    Uttoxeter, Staffordshire, UK
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Asignment Error

    Hello,

    I quote from my code:

    Code:
    selected = this.reoder_object;
    alert(this.reorder_object == selected); // Returns false!
    This is from a function which is triggered by an onmousedown event. Anyone have any idea why the alert message returns false? It's really very annoying. this.reorder_object stores a reference to a custom object constructed using a function and it seems to hold the correct value when testing it. After the assignment, the selected variable returns 'undefined'. The selected variable is declared at the start, simply by:
    Code:
    var selected = null;
    ...and it's not in any function, but the main script (so it is I believe usable by everything in the same js file...this may be wrong, thus presenting the answer to my question, nearly, but I think I'm right, and declared variables at the top of a file are usable by all functions, etc. in that file).

    The event onmousedown is set in the function which constructs the object.

    Same results in Safari and FireFox.

    Anyway know what's wrong?

    Thanks,
    Aquis

    Edit: Mistake! this.reorder_object actually stores a reference to a custom element constructed using a function. It still though has the correct value stored, and the problem is still getting the selected variable to store it's reference. I've fixed it above.
    Last edited by Aquis; Oct 11, 2006 at 14:39.

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Perhaps it's because you've misspelled reorder_object:
    Code:
    selected = this.reorder_object;
    Saul

  3. #3
    SitePoint Enthusiast Aquis's Avatar
    Join Date
    Jun 2006
    Location
    Uttoxeter, Staffordshire, UK
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...

    Darn it! This is might most common mistake!

    Thanks anyway!

    Aquis


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •