SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: return

  1. #1
    SitePoint Addict markchivs's Avatar
    Join Date
    Oct 2004
    Location
    Malvern Hills, UK
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    return

    Hi all

    I suspect this an easy one.

    What is the purpose of the return statement in the following eventHandler:
    Code:
    <select onchange='return functionCall();'>....
    compared with this statement:
    Code:
    <select onchange='functionCall();'>....
    It seams to work exactly the same for either way, but I suspect the first way is just explicitly cancelling the change event when false is returned from the function call.

    Is that right?



  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Quote Originally Posted by markchivs
    It seams to work exactly the same for either way, but I suspect the first way is just explicitly cancelling the change event when false is returned from the function call.
    That is what you might think, but the selection will be carried out regardless of what the function return.

    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Addict markchivs's Avatar
    Join Date
    Oct 2004
    Location
    Malvern Hills, UK
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lilleman
    Hi,

    That is what you might think, but the selection will be carried out regardless of what the function return.

    Yours, Erik.
    So any idea why the event Handler can have the return before the function call or not and still work erik?

    I cant turn anything up from searching on this. I'm trying to find out coz some of the code I have is written using return fun() and some is just has the fun() call.

    Weird man, inconsistent



  4. #4
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Well, certain events are cancelled when a function return false (such as the onsubmit event for a form, and onclick for a link), but it does not work for the onchange attribute on a select-list. Sorry for being unclear...

    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  5. #5
    SitePoint Addict markchivs's Avatar
    Join Date
    Oct 2004
    Location
    Malvern Hills, UK
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lilleman
    Hi,

    Well, certain events are cancelled when a function return false (such as the onsubmit event for a form, and onclick for a link), but it does not work for the onchange attribute on a select-list. Sorry for being unclear...

    Yours, Erik.
    Erik, thats crystal clear now mate thanks very much indeed. You'd think they'd make these behaviours work in the same way wouldn't you?




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
  •