Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. My recommendation would be to only load one library, either jQuery or Underscore. Use whichever library has the most features that you plan to use. Don't worry about efficiency.
  2. You can only send AJAX requests to the same domain the page is hosted on. In order to send AJAX requests to other domains the server needs to be set up to send an "Access-Control-Allow-Origin" header which includes the domain name you're sending the request from.
  3. The mail() function might turn true even if the mail wasn't sent. It returns true if the mail was accepted for delivery by the SMTP server. If your web host doesn't have an SMTP server set up for you the code won't work.
  4. I would recommend reading the W3Schools Javascript tutorial carefully. All of it is explained in detail in the tutorial. If you did not understand it the first time, read it again. I don't know where you found that script, but it's completely wrong in every way.
  5. Why don't you give a fixed name to the cookies? What exactly is your code supposed to do? A cookie is like a variable, you don't dynamically generate variables, they have specific names from the start. Try this instead: setcookie('pname', $pname, time() + (86400 * 7));
  6. It sounds like $pname, $price, $usedprice or $details have characters that are not permitted in cookie names. Make the name of the cookie something recognizable, you probably shouldn't use dynamic values for it. The "Headers already sent" error was just caused by the first error message.
  7. console.log() will show the contents of a variable. You have to have the browser's Javascript console open to see the result.
  8. It's just an id attribute. It's not doing anything in that example. Perhaps they're just trying to show that the style applied to the paragraph even when it has an id.
  9. The first site is actually ripping content from W3Schools.com, which is illegal. W3Schools.com will always be the most up to date of the two sites.
  10. You would need a server-side language, such as PHP, and a database containing all the content of your pages associated with their URLs.
  11. The audio element requires you to point to an audio file. A youtube link won't work. You need a file such as MP3, WAV or OGG. Different browsers are compatible with different formats, you can see the compatibility here: http://www.w3schools.com/html/html5_audio.asp
  12. I was just going by what was in the image. I didn't check through the code. But assuming that everything in the section follows the header, putting it on the header would work equally well.
  13. Just set "clear: both" in a CSS selector that targets the "Game Updates and Articles" heading.
  14. I consider it different, because when you use the innerHTML property you're not actually creating and adding DOM objects, you're just passing a string to the parser and letting it create the DOM instead.
  15. Perhaps it's possible to do this for an unlimited number of addends using a recursive function, but I would have to do some homework to figure it out.
  16. Table should never be used for design. It should be used for data. This article in Wikipedia pretty much explains when it's OK to use tables: https://en.wikipedia.org/wiki/Wikipedia%3aManual_of_Style/Tables#When_tables_are_appropriate
  17. Wrap it in a span and give it a title attribute. <p> Hello, I am an <span title="An example phrase.">Example</span>. </p> The title attribute can be used on any element. The appearance of the tooltip is given by the browser and cannot be modified. If you wanted to change the appearance you would have to make a Javascript program.
  18. This is more of a math problem than a programming one. Once you've figured out the mathematical solution, the programming one will be easy to implement. Is it a requirement that none of the addends are identical?
  19. There are two ways to put content on the page aside from document.write(). First, innerHTML, as mentioned before. It adds HTML code between the opening and closing tags of a particular elements. The second way is using the DOM. The DOM is a Javascript data structure that retrieves, adds, removes and manipulates elements on the page individually. Read the tutorial here: http://www.w3schools.com/js/js_htmldom.asp If you want to know why document.write() is a problem: Any time you call document.write() after the page has finished loading, everything on the page will be removed and replaced with the content you have give to document.write().
  20. What do you mean by doesn't work? Does an error message show up?
  21. Just a note: HTML 4.01 was actually just as strict as HTML 5 is, your problem was that you were using the Transitional doctype which is actually HTML 3.2.
  22. Unfortunately, borders don't accept percent values for their width. You can set the box-sizing property to include borders within the width of the box, but it will break on IE8 and older.
  23. Tables are extremely difficult to maintain. Let's say you have a website with 50 pages (this is actually below average for many websites). Let's say you decide to change from a three column layout to a two column layout. You'll find yourself going through 50 pages to fix it. With CSS, it's as simple as changing a few rules on one CSS file (unless you're using bootstrap, which puts all the presentation back into the HTML.) This is also the same reason things like bgcolor and align attributes are obsolete: The stylesheet can use a couple of rules to do this on your whole site instead of manually going through 50 pages changing the value of align attributes all over the place. There are also the accessibility problems mentioned before and browser rendering problems, and the fact that tables cannot scale for mobile devices which are more common today than desktop computers are. Both id and class can be used to select elements. id can only be used once on the page to mark a unique element, class is used to give multiple elements the same style.
  24. I'm going to give a step by step description of what your program should do: Set warrior's health to 20 Do a battle (This is a sub-procedure that should be defined) If the previous battle was won show a victory message If the previous battle was not won and the warrior is still alive, show a defeat message If the warrior's HP is between 0 and 10, show "Your health is low" If the warrior is still alive and his HP is less than 100 then return to step 2. If the warrior's HP is 100 or more, show the final victory message If the warrior is not alive, show the failure message. No code whatsoever, just a description of what I interpreted as what you really want. This is the most important aspect of programming: Finding out exactly what you want the program to do.
  25. I know what your current code does, what I actually need to know is what you really want it to do, from beginning to end. Just write a paragraph with no code explaining how the program is supposed to work. This is part of software design, if you can't describe what your program is meant to do, I don't think you'll be able to tell the computer to do it.
×
×
  • Create New...