Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Everything posted by HartleySan

  1. Yeah, for those of us not in North America, we have to try and answer each others questions while the others are sleeping. Anyway, please give me a bit longer till I have time to sit down and actually answer your question.
  2. So basically, you are logging a bunch of flight times, and you simply want to add them all up and get the total flight time in hour-minute format, right? I guess I want to know is whether or not you want to save the values you log into a database, or if you simply want to use this as a calculator, and you don't mind if all the values are deleted when you close the browser window. I feel like one issue is that you're restricting yourself to the number of entries you hard code on the page. I imagine something a little more dynamic would be helpful, no? Lastly, I don't get the 12s (12 minute?) thing either. Do you mean that each page has 12 entries on it, and you need to add up all the values for that page? Anyway, like Jonathon said, a little more info on what exactly you want to accomplish would be helpful. Thanks.
  3. Larry, if you don't mind me asking, why do you use the try-catch syntax in the function that creates an Ajax object? I ask because I have noticed that a lot of other (similar) functions for creating an Ajax object don't use that notation. Is there any particular benefit? I specifically ask because you don't do anything with the caught exception anyway. Thanks.
  4. Are you actually encoding the file name as well, or just the link to the file name? Because if you're only encoding the link, but not the actual file name as well, it'll never work. Edit: Also, in your example, you seem to be encoding a path folder, not a file. Is that okay?
  5. I didn't do anything. In the time I was commuting home from work, you made about four posts, and logically walked your way through everything, and figured the problem out on your own. Congrats! That's one of the keys to coding (and one we all have trouble with at times), debugging. It can be such a beast, but the key is breaking it into small pieces, and going from there. A good rudimentary method is to echo a lot of information at various points in the code, and see if the results are as expected. Anyway, enough of that. Good job!
  6. (This was a double post. My work PC still runs IE6, and does not properly post on this board sometimes. Sorry.)
  7. Sounds to me like the server can't find the view_users.php file at all. Are you sure your path and file name are correct? Also, while it may not be a problem, I have had issues before with using spaces in path names, and having those spaces converted to %20 improperly, etc. You might want to try moving your site to a shorter, simpler path, and trying it from there. For example, in the htdocs folder (if you're using XAMPP), make a folder called test, and put the view_users.php file in there. In which case, your URL should be the following: http://localhost/test/view_users.php Just some thoughts.
  8. Before I made my original post the other day, I scoured the Net looking for an answer. Obviously, I didn't find one, which is why I asked my question in the first place. Anyway, after doing some more searching, I did find a solution. It's a bit of a hack, but apparently, when using Ajax, you can't set a value that is already set for location.hash (i.e., you can't set the same value twice in a row). I think this is along the lines of what you were suggesting, Stuart. Anyway, the hack is pretty straightforward: You first set a value for location.hash that does not exist on your page. (The thread I saw suggested #none. After all, how often do you have an element on your page with an ID of none.) After that, you set the value you want, and boom!, it works. As such, my code change from location.hash = '#charButtons'; to the following: location.hash = '#none'; location.hash = '#charButtons'; The other issue I was having with this page in particular was the fact that whenever another character was clicked on, because the previous profile elements were completely destroyed, there wasn't enough content on the page to even jump to the anchor properly (because everything was easily displayed on one screen without the need to scroll, thus the anchor was always on the screen). As such, part two of my solution was basically a fair amount of recoding to test whether profile elements exist or not, and if they do, replacing certain nodes, as opposed to completely removing all the nodes and then recreating them. Well, I hope that all makes sense, and anyone else with this problem is able to resolve it after seeing this post. If anyone has any follow-up questions, please don't hesitate. Thanks.
  9. Well, like most things, I think the designers and engineers that really understand the technology would be strict ("correct") about their definition, while more marketing types will say whatever they need to in order to sell something.
  10. I found the solution to my problem. I will explain it in detail later. For the time being though, I'm going to remove the links from my posts, as I'd rather people didn't view them too much at the moment. Thanks.
  11. Cool. If you solved the problem, then I'm happy. When you get the chance though, definitely check out Larry's Ajax book. It's very good, and gives you everything you need to know to use Ajax for just about anything (with a little outside-of-the-box thinking). Actually, that's very much the order I went in: Larry's PHP/MySQL book, his Ajax book, and then O'Reilly's JavaScript book. (I would have gone with Larry's JS book, if he had one.) And for the record, the O'Reilly's JS book is really good, and really thorough, but it takes some time and a lot of supplementary material to properly get through, I think.
  12. Okay, things are getting interesting. For one, the location.hash works everytime in IE8, but not Chrome (which is my default browser). Furthermore, I made a page that doesn't use Ajax, but instead uses dummy data to handle each character, and when I do that, it jumps exactly how I want it to every time in IE8, but I get the weird 1-2 jump in Chrome. It's hard to explain, but if you test out the two pages below, you'll see the difference. Note that IE8 does exactly what I want in the second page below, while Chrome is a bit odd. I wonder if it's just a cross-browser thing with Ajax. Hmmm... (Links deleted.)
  13. I think a lot of people would say that a Web 2.0 (Ajax) page is dynamic enough to be called a Web application. In general though, Web applications usually refer more to things made using Java/Flex, I think. Well, let's put it this way, Gmail and Google Maps are both a whole lot of Ajax, and I'd certainly call them Web applications, so I suppose it depends on the complexity. For an interview, I think you could stretch the meaning of the term, in order to help you get a job. Most likely, the manager you're interviewing with wouldn't have much of a clue about Web technology anyway...at least in my experience.
  14. I see what you're saying, but that's not the problem. I temporary removed the Ajax from the process, and used some dummy data, at which point, everything loaded fine, AND the #charButtons anchor was properly jumped to every time, no matter what. However, with Ajax, the anchor is only jumped to once, after which, the page always jumps to the very top whenever a new character is clicked on. Edit: And just to provide some more info, the #charButtons DIV is always on the screen, regardless of what information is being removed and replaced below it. Furthermore, if I do something like the following, it works even with Ajax, but I get an annoying jumping effect: location.hash = ''; location.hash = '#charButtons';
  15. Sorry to keep answering your posts with questions, but is the grid plug-in a PHP file or a JS file? The reason I ask is because it sounds like your grid plug-in is already using Ajax. In fact, it would have to be if every time you click outside of a grid, the data is instantly re-uploaded to the database. If that's the case, I imagine you could just edit the grid functions to perform the calculations you want. Honestly though, if the values in grid 3 are just for the user to reference, and they're not stored in a database, then you do not need any Ajax beyond what the grid plug-in is doing for you. I think you have two options, really: 1) Use the pre-existing grid functions to perform the calculations and spit the info back out. 2) But probably more simple, attach a second function to the onblur event (or whatever JS event is triggering the database to be updated whenever the user clicks outside of a grid), and from that second function, perform your calculations in JS, and then further use JS to spit the values into grid 3. I know you want to use Ajax here, but you don't seem to need it. In general, Ajax calls are expensive (resource-wise), and it's best to avoid them as much as possible. If you're looking to practice Ajax for the sake of learning it, go through Larry's book first. Anyway, perhaps I am missing something (in which case, please tell me), but I think the solution to your problem is pretty straightforward. Please let me know what you think, or if you have anymore questions.
  16. To Stuart, You're 100% right, but as you well know, most people want to add that dynamic Web 2.0 feel to sites these days, so I think wanting to use Ajax is not unreasonable at all.
  17. Okay, I think I get what you're trying to say, but just for clarification: 1. When you say "two grids", do you mean two text fields (in a form)? 2. My assumption is that you're grabbing a bunch of data from two different tables, and then outputting it to various text fields. 3. From there, the user can perhaps edit the data, and upon pushing a button, can see the result of calculations performed on that data, right? Well, if that's the gist of it, you probably don't need PHP at all beyond the initial grab for the data, for which you don't need Ajax. I imagine most (if not all) mathematical operators that are possible in PHP are also possible in JavaScript. As such, you could set up an event in JavaScript to fire when the form is submitted/when a button is pressed, which will then grab the various values from the input fields (in the form), perform calculations on them, and then output that resulting data to a location of your choice. If that's what you want to do, I can give you more specifics regarding the code to do so. Keep in mind that unless you're going to have to either reinsert/reacquire data from a database after the initial loading of the page, JavaScript alone should suffice, and you won't need PHP/Ajax. Aside from accessing a database midstream, you also generally have to use Ajax to access text files/external websites, as JavaScript is not a very secure language by its very nature. Anyway, please let me know if I'm on the right track, and I'll provide you with some starter code that should work for any situation. Thanks.
  18. All right. Here's the site as it stands at the moment: (Link deleted.) The JS file that contains the location.hash is "interactivity.js". The location.hash gets set to the #charButtons anchor, which works the first time, but not for successive tries. Also, I have confirmed that the #charButtons anchor is properly jumped to every time when Ajax is not used. As such, I can only assume that Ajax is doing something. Any ideas would be much appreciated. Thank you, Stuart. And thank you everyone.
  19. I really don't like how your forum automatically capitalizes the first letter of each word in topic titles. Could you please change that? Thank you.
  20. Yeah, I'll provide a link later. The current code has alerts all over the place, etc., so I want to clean that up first. At work at the moment, so when I get home later, I'll provide a link. Thanks for your help.
  21. shaneg, what you've just described is Ajax. Ajax isn't a language so much as a server-side language (generally PHP) interacting with JavaScript, so that you can get information from a server/database on the fly and without having to reload the page. Larry's Ajax book is really good, actually. I highly recommend having finished his PHP/MySQL book first though. And having a little JavaScript knowledge doesn't hurt either. Anyway, if that's you, I'd definitely recommend the Ajax book. It's short, simple, and to the point. If you have a more immediate question that you'd like to have resolved, feel free to ask, and I (or perhaps someone else) would be more than happy to help you. Edit: More specifically, if you wouldn't mind describing in a little more detail exactly what you want to do, we can try to help you.
  22. I'm working on a site where I have Ajax loading content when certain items are clicked on, and after the Ajax is loaded, regardless of which of the items is clicked, the location.hash JS property is used to jump to the same anchor on the page (which is NOT within the Ajax-loaded content). Anyway, for whatever reason, the first time I click on something that loads content, the anchor is properly jumped to, but everytime after that, it doesn't work (as in, the anchor is not jumped too, although everything before and after the location.hash anchor assignment loads perfectly fine everytime). What's further odd is that I removed Ajax from the equation, and used some dummy data instead, so that I could use just JS to load everything. If I do that, everything loads perfectly fine, and the anchor is properly jumped to everytime. It's the weirdest thing in the world, and I can't imagine what is going on. Furthermore, when I tried to look into the issue, the only hits I could find were unrelated ones, which talk about how to create bookmarks in Ajax using location.hash. If anyone has any clue what is going on, I would be very appreciative. I could post the code too, although it's quite long and requires a server to run the PHP file.
  23. Well, I could do that, but again, I was going for an "elegant" solution. Actually, it doesn't really matter though, the more I think about it. Besides, I ended up putting everything in a self-invoking function to avoid any footprints in the global namespace. Anyway, thanks for the suggestion, and no worries on the late response.
  24. After thinking about my problem for some time, I have more or less come to the conclusion that it is pretty much impossible to do what I want unless I, A) pass an object as an argument, or create a pseudoclass in JS and attach the function as a method of the class. Anyway, simply passing an argument solved my problem, so I'll leave it at that.
×
×
  • Create New...