Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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)">
  #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
  #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.
  #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.



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





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