Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 20th, 2006, 03:31 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with onchange of DOM element

Hi,

I'm trying to dynamically create and add an input box with an anonymous Javascript function for handling the onchange event. Here is the DHTML code I'm using:

var myInput = document.createElement("input");
myInput.type = "text";
myInput.id = "myInputId";
myInput.onchange = function() { alert("foo"); }

(I am adding the input appropriately to a td and tr within a table)

However, when I change the contents I'm not getting the alert I expect. I've looked through chapter 6 of the book (after having read it) and can't find anything to help me out in this situation.

What am I doing wrong?

Thanks,
John

Reply With Quote
  #2 (permalink)  
Old March 20th, 2006, 03:33 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

onchange fires when the text has changed *and* the focus is lost. It doesn't fire as the user types.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #3 (permalink)  
Old March 20th, 2006, 07:27 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, sorry. I guess my original question wasn't that clear. I meant to say that when I enter text *and* tab off, the event doesn't fire.

Thanks,
John

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML DOM - clone form element could not be aligned Shibu Javascript 5 November 15th, 2008 11:24 PM
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
Need to Click Element in DOM document AccessAasif@aol.com C# 2005 1 October 18th, 2007 03:38 AM
How to Click Element in DOM document AccessAasif@aol.com C# 1 October 18th, 2007 03:03 AM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM



All times are GMT -4. The time now is 04:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.