Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'event handler'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. I am going through chapter 10 and I have run into a problem with focus and blur events on multiple form elements. I have a function which adds multiple events and handlers to elements. function addPlaceholderHandlers(elem) { 'use strict'; elem.onfocus = setOpacity; elem.onkeydown = removePlaceholder; elem.onblur = addPlaceholder; } // end of addPlaceholderHandlers function Then I run the following code in window.onload window.onload = function() { 'use strict'; var elements = document.getElementById('caseEval').childNodes; for (var i = 0, count = elements.length; i < count; i++) { var element = elements[i]; addPlaceholderHandlers(element); } }; The onkeydown is the only code that actually runs, and I suspect that this is so because the focus and blur events do not bubble. The obvious solution is to use the addEventHandler and set the phase to true to "capture" the event, however, I am not aware that IE has an equivalent for phase. Aside from referencing each individual element, adding the event to each element, and then setting an event handler for each individual element, is there a better alternative for selecting multiple elements when using the focus and blur?or should I change my event handlers to something other then: function removePlaceholder(evt) { 'use strict'; // get reference to the event if (!evt) evt = window.evt; // element triggering the event var target = evt.target || evt.srcElement; if (target.value === target.defaultValue) { target.value = ''; } target.style.color = '#000'; } // end of removePlaceholder function I would just like to add that I absolutely love this book and the support in this forum. I have never done any programming until three or so weeks ago, and I didn't even know what HTML was just a few weeks prior to that. I feel that this book is so well written, concise in its examples, and relevant that it should be in every beginners and maybe some intermediate programmer's bookshelf. You have definitely gained a lifelong reader.
×
×
  • Create New...