Jump to content
Larry Ullman's Book Forums

JohnS

Members
  • Posts

    5
  • Joined

  • Last visited

Recent Profile Visitors

572 profile views

JohnS's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Yes, it was quite clear, and I thought I understood it. So then why did your Fig.B of Pg.5 execute correctly?
  2. Re: program first.php The program works fine when I enter the URL as: http://localhost/first.php exactly as shown in Fig.A on Pg.4. So far, so good! However, when I open the file using my local path: file:///Applications/MAMP/htdocs/Ch01/first.php it does not execute the HTML, but displays the source code of first.php, but with the <?php ?> tag removed! Fig.B on Pg.5, shows the HTML executing normally (because there is no actual PHP code between the PHP tags). You even say "not that this particular script is affected either way." ​Of course, if I change the name of the file from first.php to first.html, then it works as a normal HTML program, but Fig.B shows the name as first.php Shouldn't your browser fail to run a local file with a .php extension? Any idea what is going on here?
  3. On p.138 the sphere program is modified. In step 2, he says to change the assignment to: var radius = document.getElementById('radius'); and in step 3, to use: if (radius && (radius.value > 0)) { What is the point of this extra complication? In other words, why not just use the original: var radius = document.getElementById('radius').value; and then simply test for: if (radius > 0) { I've written versions both his way and my way, and they both work the same. I don't understand what he means by: 'The first part of this condition confirms that the radius variable has a TRUE value. So long as the document.getElementById() method was able to find an element in the page that has an id of radius, this will be the case.' We know that the radius field exists because we wrote it into the form in our HTML file. Why would we have to test whether the field exists?
  4. I got Firebug, and now I can see what was going on. So this problem all stemmed from the use of the “number” type for the Quantity field, which is odd as it was pointed out on p.103, that it was done on purpose. I changed the type to “text” like all the other input fields, and the program behaved the way the book said it should: entering numbers in all the fields gave the correct numerical Total, while entering a string in any of the fields gave ‘NaN’ for the Total. As an experiment I changed the type of all the fields to “number”. It still functions correctly when numbers are entered in all the fields, but gives an answer of ‘-3’ when text is entered in Quantity. The worst possible outcome: an incorrectly calculated result with no indication that an error has occurred! The strangest thing is the comment on p.103 that “…the number type doesn’t deal well with decimals.” Both the number type and the text type handled the decimal number computations just fine.
  5. For the Chapter 4 shopping example, on p.107: I've got it working when I enter valid numbers, just as in Figure 4.4, but when I enter the string 'cat' in the Quantity field, as you do in Figure 4.5, I get -3.00 in the Total field, not NaN as shown in the book. I realize that the eventual answer is going to be to validate all input before doing any calculations, but I'd still like to know what's going on here, and why my results are not agreeing with the book. Thanks.
×
×
  • Create New...