Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

  • Days Won


David last won the day on June 27 2012

David had the most liked content!

Community Reputation

1 Neutral

About David

  • Rank
  1. Modified the recursive function on page 19 to return divs instead of an ordered list. Function: function make_list($parent, $sub=FALSE) { // set attribute if (!$sub) { $attribute = 'id="menu"'; } else { $attribute = 'class="submenu"'; } // set tasks access global $tasks; foreach ($parent as $task_id => $todo) { // new loop? if (!$sub) { echo '<div id="main">'; } // build div echo '&
  2. There's no Bellyache section on the forum (or if there is, I'm blind), so the alternative is putting it right here in public eye. My apologies. I'm confused on the benefit of using HTML_QuickForms2 in terms of actual learning value. Yes, it's a class, much like the built-in PHP classes already being used, and I accept the benefit of having it handle the heavy lifting for forms (validation, etc), but from a learning perspective, it would seem that actually working through the process 'by-hand' might deliver substantially more 'rubber-meets-the-road' value. It's one of the rare disap
  3. The result of implementing Suggestion (1) is: The string looks to be constructed as one should expect. ===================================================== The result of implementing Suggestion (2) is: The php page looks to return the expected value. ===================================================== Alerting the ready.State variable produces the following sequence: ready.State is: 1 ready.State is: 2 ready.State is: 4 ===================================================== And *here* is the interesting part: "ajax.status is: 0" For som
  4. What I've often done to help preserve my sanity is just: a) download the code, and; copy and paste, and; c) pretend I wrote it all myself. Seriously though, having a good look at the working rendition of the code will often reveal niggling - but show-stopping - errors that may have slipped in unawares while you were typing. ~ David
  5. When you say "post . . . how a value is assigned to the data variable", do you mean this? function sendThingy() { 'use strict'; // Get form elements: var comments = document.getElementById('comments'); var user = document.getElementById('user'); if (comments.value.length > 0) { var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange = function() { if (ajax.readyState == 4) { if ( (ajax.status >= 200 && ajax.status < 300) || (ajax.status == 304) ) { document.getElementById('chat').innerHTML = ajax.responseText; } else {
  6. Have a situation where - when submitting form data to a php script - the ajax script stalls at: ajax.send(data); When the script stalls, it throws no error messages and returns no results. It just stalls. The php script runs all of its scripty things perfectly sans ajax, so I know the php and mysql is solid. It's just when it comes to incorporating the ajax that there is any issue. But wait - there's more. When the script is under the influence of ajax, and stalls, the Firebug console displays this line of text in red (red obviously indicating some kind of error, even though there's
  7. Gave that a try and doggone if she still don't stall out just before sending the query. I did, however, update the sample code above (or below or wherever it is in relation to this post) so it reflects your suggestion. ~ David
  8. No error is shown, instead, the php code merely stops executing. The query itself runs just fine on the database. I can put real, live zero's in their respective columns until the hens come home, so the query is proven sound. In addition, any number between 1 and 5 works just fine when run through the php script. However, when a 'zero' gets selected in the drop-down and runs through the php script, it (the script) wonks out right at the point where it should be sending the query. The 'else' error displays instead. Seems the script won't recognize 'zero' as an integer, even though i
  9. Have a select situated like so: $number = range(0,5); <select name="amount"> foreach ($number as $key => $value) { echo '<option value="' . $key . '">' . $value . '</option>'; } </select> The handling script contains: if (!empty($_POST['amount'])) { $a = mysqli_real_escape_string($dbc, $_POST['amount']); $b = (integer)$a; } else { $b = false; } It works swimmingly enough, until a '0' $key-value buggers the handling script. The script swears on a stack of manuals it's being fed something other than the integer 'zero'. How does o
  10. One method for passing attractive variables between scripts is to append them to an URL like so: <a href="edit.php?x=1">edit</a> The issue being that "x=1", while provocatively visible in the URL, is easily coerced to become "x=99", or some other arbitrary value of dark intent and high suspicion. Is it merely that I have yet to find the session-based solution for this in the book? Obvious session assignments, i.e., registering a user name as a session variable, are straightforward. But the example listed above seems to present a different sort of challenge. ~ D
  11. Indeed it does. Thank you. And since there are already sessions at work, the task is conveniently accomplished. Makes me wince to recall how profound the original question appeared at the time. ~ David
  12. Hello there! The thread referenced (at the bottom) covers how to display two forms on a single page. However . . . In the case referenced, both forms are visible on the page by default, and it is only *after* a submit has been detected that the script detects the form sent, and calls the appropriate code. It seems possible to display only one of the forms based on a user's site visit status. For example, assume a page contains code for both 'Form A' and 'Form B'. What I'm looking for is: 1) When the user visits the page for the first time, 'Form A' is displayed by d
  13. Attempted to generate a tooltip from code listed on pages 384 and 385. HTML was looking like this: <div> <label for="username">Username<span class="tooltip">Some snappy tooltip here</span></label> <input type="text" name="username" id="username"/> </div> Tested page. No tooltip. Instead, the console.log shows: TypeError: target.previousSibling.lastChild is null "target.previousSibling.lastChild.style.visibility = 'visible';" Tested the download files. Tooltip works. My code is exactly like the download files, and
  14. The script for the To-Do List in chapter 4 (page 204) allows for adding new list entries, but no way to edit or delete (and maybe re-order) the entries after they've been entered. Since the data is only stored in a client-side array, can those element values be accessed for editing? ~ David
  15. Odd that: 1) Other forms work, but not this one. Presuming this form uses the same database script as the other. 2) Although error messages are assigned, you only see “Error!” - and not corresponding error message. And most odd of all is: 3) You downloaded the completed lesson and tested the form (and it) behaves in exactly the same way... I didn't see anything wrong, but that don't mean it aint there. Commenting everything out - and testing one element at a time until it works correctly - usually helps me track down, club* and remove the funky monkey screwing with my code.
  • Create New...