Results 1 to 8 of 8

Thread: Can you have more than one event on an <INPUT> event attribute?

  1. #1
    Join Date
    Jan 2006
    Location
    Derbyshire, UK
    Posts
    74
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Can you have more than one event on an <INPUT> event attribute?

    I have two <INPUT> tags that separately work OK...

    Code:
    <input name="ysearch" id="ysearch" type="text" value="Search" onKeyPress="checkKey()" onFocus="if (this.value=='Search'){this.value='';};return false;" onBlur="if (this.value==''){this.value='Search';return false;}">
    and

    Code:
    <input name="ysearch" id="ysearch" type="text" value="" onKeyPress="checkKey()" onFocus="javascript:collapseQS.slideit()" onBlur="javascript:collapseQS.slideit()">
    Can the two different onFocus and onBlur events be merged so two events take place?

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,040
    Thanks
    16
    Thanked 318 Times in 316 Posts
    Blog Entries
    14

    Default

    Yes, you should just be able to combine them by putting a semi-colon between;
    Last edited by Beverleyh; 08-04-2010 at 02:36 PM.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Jan 2006
    Location
    Derbyshire, UK
    Posts
    74
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default

    Thanks Beverleyh but that doesn't work. It achieves the Search insert but doesn't invoke the javascript. I've tried it with the javascript event first but it's just the same.

    You can see the javascript working here (searchBox top-right)...
    http://www.barlborough.org/index.htm#home

    Here's the same page but with the events combined...
    http://www.barlborough.org/index-test-1.htm#home

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,040
    Thanks
    16
    Thanked 318 Times in 316 Posts
    Blog Entries
    14

    Default

    Lose your current Search insert and try this one instead;

    In your head section;
    Code:
    <script type="text/javascript">
    function clearText(field){
        if (field.defaultValue == field.value) field.value = '';
        else if (field.value == '') field.value = field.defaultValue; }
    </script>
    Your revised input field;
    Code:
    <input name="ysearch" id="ysearch" type="text" value="Search" onKeyPress="checkKey()" onFocus="javascript:collapseQS.slideit();clearText(this)" onBlur="javascript:collapseQS.slideit();clearText(this)">
    Last edited by Beverleyh; 08-04-2010 at 02:47 PM. Reason: code corrected
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  5. The Following User Says Thank You to Beverleyh For This Useful Post:

    Burgin (08-04-2010)

  6. #5
    Join Date
    Jan 2006
    Location
    Derbyshire, UK
    Posts
    74
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default

    That's cracked it... ta very much. Your time's appreciated.

  7. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,040
    Thanks
    16
    Thanked 318 Times in 316 Posts
    Blog Entries
    14

    Default

    No problem - BTW - I'm from your neck of the woods (Chesterfield)

    Small world, eh?
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  8. #7
    Join Date
    Jan 2006
    Location
    Derbyshire, UK
    Posts
    74
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default

    Sure is... BTW Fast-Edit looks very interesting, could be just what I'm looking for.

  9. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,040
    Thanks
    16
    Thanked 318 Times in 316 Posts
    Blog Entries
    14

    Default

    Good stuff - Fast Edit 2 is coming out in a few months though and that has an automatic sub-category/multi-level menu, so keep checking back for updates
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

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
  •