Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

Everything posted by krompir

  1. Thank you for your help. I set up a similar event testing function, and it turns out that the keydown was creating some issues, since it was not firing when I expected. BTW, the reason "nothing was working" was because I didn't start my server. I was so preoccupied with trying to get this to work, that I ignored the simple things. I remembered that Larry wrote to just step away, eat an apple...and then come back fresh, and all of a sudden everything was making sense. Thank you for all your help yet again.
  2. Is it possible to select an attribute of an input tag? For example, if you had: <input type="text" value="Your Name"> Is it possible to select the value attribute of the input tag?
  3. Thank you for your help. I am afraid that now nothing works. I am really confused, so I will start at the beginning. How would you select multiple form elements including a text area?
  4. I tried posting the relevant HTML, but it will not render. Sorry.
  5. I was thinking about using the label like this (var form = document.getElementById('caseEval'); form.getElementsByTagName('label') ) and moving it dynamically into the text box, so that users w/out Javascript would have the same functionality with the form, although, I am not sure that that would solve my phase problem. I have so many ideas, just difficulty executing them. The code you requested is below. It seems repetitive, but I don't know how else to reference target and event. As always, very grateful for your time and help. function setOpacity(evt) { 'use strict'; if (!ev
  6. 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 < co
  7. Ok. Thank you for responding. At first I must admit I was confused. I did as you suggested, and looked up some ECMAScript specs and read chapter 9 which covered DOM in detail and I am further enlightened, although a little intimidated by the vast amount of possibilities and the realization of just how much I don't know. Thank you again for all your help.
  8. That is correct events.js works. Five weeks ago I didn't know what HTML was, so you will have to forgive me that I am not in the point at the book where debugging is covered, so I am not certain where to even begin, much less how. I will tell you however, that the set handlers function is the same in both events.js and events2.js. I do have return false at the end of set handlers, and the addEvent function works with my other examples. After closer examination of chapter 8, I found this interesting tidbit: "The problem with returning false to prevent the default browser behavior is that
  9. 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() ----
  10. I figured it out. I placed the var message containing the opening tag of the ordered list within the for loop, creating a new list each time. Thank you for your help.
  11. I have done as you suggested and the elements in the array are being displayed. However, with each new item added the first item is deleted, displaying only the last item, instead of an ordered list. // create a new object var employee = { firstName: firstName, lastName: lastName, department: department, hireDate: new Date(), getName: function(){ return this.lastName + ', ' + this.firstName; } }; // add items to an array newHires.push(employee.firstName); // create output as HTML for (var i = 0, counter = newHires.length; i < counter; i++) { var message = ' [b] Employee Added:[
  12. For the last exercise in review and pursue: "If you’re feeling particularly confident, combine the techniques demonstrated in tasks.js and employee.js so that an array of employee objects is created." (p. 218). How does one proceed to create an array of objects? I am quite lost. Most of my attempts have resulted in [object Object] being returned or an ordered list listing each object element under a new list item. The original code is: // employee.js // This script creates an object using form data. // Function called when the form is submitted. // Function creates a new
  • Create New...