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: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1
This is the forum to discuss the Wrox book Beginning JavaScript, 3rd Edition by Paul Wilton, Jeremy McPeak; ISBN: 9780470051511
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 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 July 15th, 2008, 12:37 PM
Tim Tim is offline
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 5 example (p. 173)

Hmm. I notice this forum does not seem to appear all that popular - I hope someone actually responds:

Anyway, I followed the example pretty well until the explanation on page 175. Two things that threw me:

1. the explanation refers to a link (but the example uses a straight forward <img> tag and there are no <a> tags in the example.

2. there is no explanation for the "return" as in ".. onclick="return changeImg(1)">
Reply With Quote
  #2 (permalink)  
Old July 15th, 2008, 01:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I don't have the book so I don't know what page 175 is, but the return statement is often used that if there is a value returned from the method, the click action will continue; if false is returned, it is not processed. Sometimes return false is added so that the actual action doesn't occur (such as with .NET buttons to prevent them from posting back to the server).

Brian
Reply With Quote
  #3 (permalink)  
Old July 15th, 2008, 03:26 PM
Tim Tim is offline
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you so much for responding!

I am not quite sure I understand your response.

The example in the book is as follows:
<img name="img1" src="x.gif" onclick="return changeImg()">

What confuses me is that "return" comes before the function. In this case, the last line of changeImg()'s procedure is "return false."

The changeImg() function itself merely changes the src property of the image to swap images.
Reply With Quote
  #4 (permalink)  
Old August 3rd, 2008, 09:04 PM
Registered User
 
Join Date: Jul 2008
Location: , , Western Sahara.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,Tim:
I'm John and a beginner too. I just read it on the same page as you questioned. you can turn one page bake and find a title "Event Handlers as Attributes" where you could get a anwser.( key sentence is " the value returned by onclick = "return linkSomePage_onclick()" is used by JavaScript to decide whether the normal actin of the link, that is,going to a new page , should occur." Good luck.

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
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
Beginning Dreamweaver MX 2004 - Pgs 173-185 maezee Dreamweaver (all versions) 4 July 24th, 2005 02:22 AM
chapter 6, page 173-175, error in sql syntax vkranendonk BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 May 26th, 2004 12:30 PM
ASP Error Message 173 renisar Classic ASP Databases 9 December 19th, 2003 09:05 AM



All times are GMT -4. The time now is 07:00 PM.


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