Results 1 to 4 of 4

Thread: Calling two functions on one event handler

  1. #1
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Calling two functions on one event handler

    Ok I have this event on a text box that clears the text inside when focused on, but I also want it to change to light blue like the other text boxes I have when clicked on.

    The other boxes use onFocus events, and I'm having trouble figuring out how to call both functions with the one event handler, I would like to not have to add the light blue background as a function to my clearing effect, but if it must be done thats ok.

    Heres my code...

    This is to clear the text box...
    Code:
    function checkclear(what){
    if(!what._haschanged){
      what.value=''
    };
    what._haschanged=true;
    }
    And this is what makes the BG's light blue when focused on...
    Code:
    onfocus="this.className='focus'" onblur="this.className='normal'"
    Which calls this Internal CSS...
    Code:
    .normal
    {
        background-color:white;
    }
    
    .focus
    {
        background-color:lightblue;
    }
    If I'm not clear ask any questions that you like.

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    It is possible to attach more than 1 function to an event

    If you had a function called test1() and another called test2() here is how you would call them both for onfocus.

    onFocus="test1();test2()"

  3. #3
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    well I thought I tried that, but I'll try it again

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Here, do this:
    Code:
    onfocus="checkclear();this.className='focus';" onblur="this.className='normal';"
    Jeremy | jfein.net

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
  •