Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'event handling'.

  • 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 4 results

  1. This one's a simple question, I am just trying to figure out where the supplementary markup code for the code is? I am fine coding this myself though, I was just making sure otherwise I will also check the source files provided on Larry Ullman's site. Figure 8.7/8.8 displays the form on reporting events on page 292. Thanks, Mark
  2. This chapter discusses a topic on keyboard events. I have provided links to my dev website. On page 284, the "change" event is added to the U.addEvent method. U.addEvent(U.$('comments'), 'change', limitText); http://www.sandiegowebcreative.com/text.html On page 284, the "keyup" event is added to the U.addEvent method. U.addEvent(U.$('comments'), 'keyup', limitText); http://www.sandiegowebcreative.com/text2.html I don't notice the difference between the two. I receive the same results from my browser, or I may not be noticing that which is obvious (or not as obvious?) Anyone come across this?
  3. in chapter 8 there is a file (events2.js) updated to use the Utilities Object. However, when linked to events.html the code does not work. It resets the form on submit. The difference I found is the anonymous function called for the onload event of the window object. What I don't understand is why the events2.js doesn't work: ---- events2.js ---- window.onload = function() { 'use strict'; U.addEvent(U.$('theForm'), 'submit', setHandlers); }; ---- events.js ---- window.onload = function() { 'use strict'; U.$('theForm').onsubmit = setHandlers; }; ---- addEvent() ---- addEvent: function(obj, type, fn) { 'use strict'; if (obj && obj.addEventListener) { // W3C obj.addEventListener(type, fn, false); } else if (obj && obj.attachEvent) { // Older IE obj.attachEvent('on' + type, fn); } }, // End of addEvent() function.
  4. I don't understand how to use e - so I've created a small form to test my understanding of event handling. The form requires a radio button to be checked. If I submit the form without checking a button the error message appears but then the form appears to be locked and I can't check a button. Firebug stops at this line U.stopDefault(e); which seems correct. Do I need to reset something? HTML <body> <form id="optInForm" method="post" action="optIn.php"> <fieldset><legend>Agree</legend> <label for="yes">Yes </label><input type="radio" name="optIn" value="TRUE" /> <label for="no">No </label><input type="radio" name="optIn" value="FALSE" /> <input type="submit" value="submit" id="submit"/> <input type="hidden" name="submitted" value="TRUE" /> <div id="errMsg"></div> </fieldset> </form> <script type="text/javascript" src="optIn.js"></script> <script type="text/javascript" src="utilities.js"></script> </body> optIn.js function checkForm() { 'use strict'; var optIn = document.getElementsByName('optIn'); var msg = ''; var chosen = null; for (var i=0, il = optIn.length; i<il; i++) { if (optIn[i].checked){ chosen = optIn[i].value; } } if (chosen === null) { msg='Please select Yes or No'; U.setText('errMsg', msg); U.stopDefault(e); } else { return true; } } // end checkForm function window.onload=function(){ 'use strict'; U.addEvent(U.$('optInForm'),'submit', checkForm); }; utilities.js var U = { $: function(id) { 'use strict'; if (typeof id =='string'){ return document.getElementById(id); } }, // end $ method setText: function(id, message) { 'use strict'; if ((typeof id == 'string') && (typeof message == 'string')) { var output = this.$(id); if (!output) return false; if (output.textContent !== undefined) { output.textContent = message; } else { output.innerText = message; } return true; } }, //end setText method addEvent: function(obj, type, fn) { 'use strict'; if (obj && obj.addEventListener) { obj.addEventListener(type, fn, false); } else if (obj && obj.attachEvent) { obj.attachEvent('on' + type, fn); } }, //end addEvent method removeEvent: function(obj, type, fn) { 'use strict'; if (obj && obj.removeEventListener) { obj.removeEventListener(type, fn, false); } else if (obj && obj.detachEvent) { obj.detachEvent('on' + type, fn); } }, //end removeEvent method stopDefault: function(e) { 'use strict'; e = e || window.event; if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } return false; } // end stopDefault method }; // end U class def
×
×
  • Create New...