Jump to content

jeffman

Members
  • Posts

    7,761
  • Joined

  • Last visited

Everything posted by jeffman

  1. jeffman

    GET(action)

    var url = "autocomplete.php?action=complete&id=" + escape(completeField.value); There it is.
  2. Stop using framesets and 1990s-style HTML. If you explain your motivation for using frames, someone might be able to suggest the best alternative. There are several.
  3. jeffman

    GET(action)

    Yes. In the tutorial, this function assigns a reference to the user input to the global variable completeField. I see no reason to create a global variable in this way, but that's how it works.function init() completeField = document.getElementById("complete-field");}
  4. jeffman

    GET(action)

    I'm not sure what you mean by "grabbed." If by "links" you mean the address specified by the action field, then yes, GET is related to that -- but only if the form is submitted normally, so that the action gets a query string added. If you are using AJAX, name-value pairs must be added to the query string programmatically, and they don't have to be added at all. In your case, whatever happens, probably happens in the doCompletion function.
  5. Since you are using sets of data, would it be simpler to start the process by using arrays?
  6. Obviously, you will need separate CSS for that, but there is no way for CSS to know what document is loaded in the browser. You will have to do that manually, or with JavaScript, or using a server-side platform like PHP or ASP.NET. If you only have a few pages, it's easiest to do it manually. A programmatic solution is more efficient, but not easy to figure out if you are new to programming.
  7. You have maybe forgotten about caching. Once a user has downloaded a js file, it will stay cached, and subsequent requests won't be made. The browser will used the cached version instead. Back in the 90s, when everyone had crappy modems and servers lived on 512K routers instead of T3 routers, small bandwidth savings mattered. Today, even if we didn't have caching, a normal HTTP request is nothing to worry about. You won't save any noticeable time at all. Most of the latency I see these days comes from slow DNS look-ups and Google Analytics. YMMV
  8. The easiest thing is to move all that PHP, with the opening and closing <?php ?>tags, after the closing </form> tag. An alternative is to save the table to a string variable instead of printing it right away. (That's better practice than a lot of print/echo statements anyway.) Use the concatenation operator to build the string one piece at a time: $myTableString = ""; // to initialize it$myTableString .= "Hello";$myTableString .= "next part";$myTableString .= "some more";$myTableString .= "bye." Then simply echo it where you want the table to be: </form><?php echo $myTableString ?></body>
  9. Perhaps you are unaware that you can embed PHP tags anywhere inside a document? They don't have to be at the top. Also, there can be multiple PHP tags in a single document, and they all share the same global space. This means that you can execute code at the top of the document, and any variables declared there will be available in the middle of the document. So you can easily run some code at the top, then output a bunch of HTML, and then execute some more PHP and use it to output different HTML, and so on. I can't tell if that solves your problem. I just thought I'd throw something out there that sounded close.
  10. I was referring to this: If Javascript is disabled then that code never runs and the form submits normally. Depending on your application, you may want to plan for this case.
  11. You will probably need to send data to the server script so it knows whether to respond with a complete document or with data formatted for AJAX. Testing for the value of a hidden form field is usually enough.
  12. PLEASE post the HTML for your header and explain exactly how you would like it to change. (Do you want text only to change, an image to change, background color to change?) Also post the HTML for the element the user clicks on to make the change happen.
  13. We do best when you provide your HTML and explain the problem in a little more detail. The more questions we have to ask, the longer it takes.
  14. HTML5 does not support cell-padding or cell-spacing. The CSS padding property is supported, and browsers often set a positive default value for that. Changing it might help. You should also look at table specific CSS properties. border-collapse might be useful here.
  15. Exactly what are you confused about?
  16. jeffman

    Need a tip

    Where to start depends on what you need to do. If you really don't need anything, I would start with JavaScript. It will work with what you already know more directly than PHP will.
  17. Yours: if ($item['TITLE']; = "") Corrected: if ($item['TITLE'] == "") Note that this still might throw a warning (not an error) if $item['TITLE'] has never been set in the first place. If that's possible, this would work: if (empty($item['TITLE']) )
  18. Remember that an element can have more than one class. The great thing about removeClass is that you can remove one (or more) classes at a time, you don't have to remove all of them. So in this situation, you can give your .selections element a second class. That will give you another selector to search for. Of course, if there is only one element you need to do this to, it can have an id that you search for.
  19. The 100% fool-proof way to do that is to use some server-side scripting. If you're up for it and your server has PHP enabled, ask me about that. Otherwise, JavaScript will work. The only downside is that a very small number of people have JavaScript turned off. If that doesn't worry you, then this will work. <input type="radio" id="male"><script type='text/javascript'> if (location.search != "") { var id = location.search.split("?")[1]; document.getElementById(id).checked = "checked"; }</script> And the link from the other page should look like this: <a href="mypage.html?male"> The ?male is called a query string. It's normally used to send data to your server, but it can be used like this also.1. The script looks for a query string. If it doesn't find one, it terminates.2. It finds the value of the query string and strips off the ?3. It searches your document for an element whose id matches the query string. When it finds it, it sets the checked property.I chose the id male as an example. You can use anything you want. Just keep it to ordinary letters and numbers, or they will get encoded, and I didn't build that into the script. Also, to keep things simple, I put the script right after the radio element. It can go anywhere after the radio element, but not before, or it won't work. I'd have to make the script a little more complicated than it needs to be. I suggest testing it with no changes to verify that it works. Then adapt it to your needs.
  20. The font-family needs to be set for the textareas.
  21. Use div elements. Please explain your background problems with that. I suspect it has to do with the height of the divs. Div heights are determined by the height of their contents. If your divs are not high enough to fill the window, then the body background will show through at the bottom. You can also set the height of one or both divs using CSS, but that can get tricky. Or it might work if the background of the body is the same as the background of one or both divs. At this point, I'm just guessing.
  22. Fix these selectors before you try anything else: #dblist a:s2:visited #dblist a:s3:visited
  23. Yes. Each var would represent a separate "thread." If each "thread" calls the same process, or affects the environment in a similar way, then be prepared for that. An interesting fact.var i = setInterval(someFunc, 1000);i = setInterval(otherFunc, 1000); You would think that since the second call to setInterval overwrites the value of i, then the first timer would be nullified. Not true. That is because i is not some sort of timer object. It is only a Number, specifically the ID of a "timer object" that the browser tracks internally. The only way to stop a timer initialized by setInterval is by calling clearInterval. If you don't call clearInterval before calling setInterval, you could end up with an arbitrary number of timers all running simultaneously. That could easily happen if you called setInterval in a loop or in response to a user event, like a mouseclick. As to setting the value of a timer ID to null, that would give you an internal check to see if a timer might already be running. When you pass a variable to clearInterval, its value does not change. If you nullify the variable immediately after passing it to clearInterval, then a subsequent process can check the value of the timer ID and know if a timer is in fact running. I would personally be much happier if JavaScript provided an actual Timer object that you could manipulate explicitly. I find the absence of such a thing most conspicuous. jQuery has such stuff, but that's no excuse.
  24. I have apps that do that. It's efficient code that makes your intention very obvious.
  25. Look up insertBefore(). The only trick is getting a reference to the correct node.
×
×
  • Create New...