Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Ingolme

  1. You might be confusing data storage with data representation. If you put a 10.00 in the database, it will store exactly 10, since the decimals aren't needed they're not shown. If you want to see the decimals, then your software will have to force a precision on the number when converting it to a string. I don't know what programming language you use, but it's up to the programming language to determine how the numbers are represented on the website or application.
  2. It's not possible with plain CSS. since the scrolling causes any overflowing content to be hidden. Javascript could do it if the vertical dropdowns are outside of the menu and moved into place with absolute positioning.
  3. The page doesn't describe what "Jekyll" actually is. Is it a programming language? W3Schools tutorials generally only makes tutorials for technologies that are used industry-wide. If they were to make tutorials for every obscure language and tool there would be thousands of tutorials and I don't think they have the time for it.
  4. Math.random() * 10 gives you a random number in the interval between 0 and 10. If you floor it, 10 will always be left out because random() never returns 1, leaving it at an even distribution between 0 and 9. If you add 1 to that the end result is a number between 1 and 10, so Math.floor(Math.random() * 10 + 1) is a valid way to fairly choose a number between 1 and 10. This excludes zero, if you want zero then you will have to include 11 in your equation and not add the "+1" Mozilla's example is just a more general solution for if you want control over the range, but if you replace max with 10 and min with 1 the formula still simplifies down to Math.floor(Math.random() * 10 + 1). I mentioned the problem with round earlier, but a graphic representation should make it clear. The distribution of the numbers on the number line for round is unfair. 0 1 2 3 4 5 6 7 8 9 10 Number line: |-------|-------|-------|-------|-------|-------|-------|-------|-------|-------| | | Math.round() |-0-|---1---|---2---|---3---|---4---|---5---|---6---|---7---|---8---|---9---|-10| | | Math.floor() |---0---|---1---|---2---|---3---|---4---|---5---|---6---|---7---|---8---|---9---| As seen above, the amount of the number line dedicated 0 and 10 is half of the other numbers and there are 11 possible output values for the function when you use round(). The code Math.floor(Math.random()*(max+1)+min), will not give desired results if you plug in 10 and 1. If you plug in those numbers, your formula simplifies to Math.floor(Math.random() * 11 + 1) which will give you random integers between 1 and 11. In summary, I believe that the W3Schools example is not misleading and is, actually, the only possible way to generate evenly distributed random integers between 1 and 10 in Javascript. Any other code that does that will end up simplifying to that same expression.
  5. You can click on the "Report error" button at the bottom of the page to let the W3Schools staff know that that page has an error.
  6. You only need to make one topic for your question. There are answers in your other topic. I'm closing this one.
  7. It's built using HTML, CSS and Javascript.
  8. The "+1" makes it as likely as the other numbers. If you use Math.round(), what you get is that numbers on both ends have only half the probability as the numbers in the middle, and in your example 11 would be the number at the end.
  9. CSS wouldn't be able to do it. You will need to do some math and write a Javascript program to determine where to place the image. It takes some work so there's no short code snippet that could be provided.
  10. They don't. There's a "report error" link at the bottom of each page if it has something incorrect or incomplete.
  11. That code looks correct. If the <div class="card-content"> element has a float CSS property then it would cover up the image with an invisible wall and prevent clicks from getting through to the image. There would be no way to solve it without changing the CSS.
  12. It won't stop the responsive behavior of the layout itself, but you can remove the <meta> viewport tag from the HTML template. That will cause mobile devices to display the page at a desktop scale.
  13. Cut out everything from top.htm except for the section of code that contains the menu. w3-include is not like an iframe, it does not need a complete HTML document. You can put the Javascript into an external .js file and use a <script> tag to include it right below the place where you include top.htm. top.htm should be reduced to just this: <div class="topnav" id="myTopnav"> <a href="../index.htm">Home</a> <a href="../whatsnew.htm">What's New</a> <a href="../calculators.htm">Calculators</a> <div class="dropdown"> <button class="dropbtn">Tax <i class="fa fa-caret-down"></i> </button> <div class="dropdown-content"> <a href="../personaltax.htm">Personal Tax</a> <a href="../taxrates.htm">Tax Rates</a> </div> </div> <div class="dropdown"> <button class="dropbtn">Financial Planning <i class="fa fa-caret-down"></i> </button> <div class="dropdown-content"> <a href="../freein30.htm">Free In 30!</a> <a href="../save_money.htm">Save Money</a> </div> </div> <a href="../resources.htm">Resources</a> <a href="../sitemap.htm">Site Map</a> <!-- the &#9776 provides the hamburger icon --> <a href="#" class="icon">&#9776;</a> </div> In the external Javascript file, you would put your Javascript function and then you would add some code to attach an event listener to the link as follows: var icon = document.querySelector("#myTopNav .icon"); icon.addEventListener("click", myFunction); The code on your main HTML page should look something like this, but with the correct path to your external Javascript file. <div w3-include-html="_borders/top.htm"></div> <script> includeHTML(); </script> <script src="filename.js"></script> My preference is to not use Javascript includes because it slows down the page loading, search engines can't see the content and users who block Javascript won't see anything on your page. Usually you'll have a server-side programming language which does the includes for you.
  14. I just went through your code, you haven't written any Javascript, so I can't point out where you might be having any mistakes.
  15. I would guess that includeHTML() won't actually run any Javascript that is in the included HTML file, you should put that Javascript in a separate file and use a <script> tag in the main document for it. The w3-include should probably only be used for short pieces of pure HTML which should not contain any <!DOCTYPE>, <html>, <head>, <body>, <style> or <script> tags. Things start behaving unpredictably if you try to do anything other than load plain static content.
  16. What exactly are you trying to achieve? With a purely client-side database anybody can register and log into your website and set their own permissions. Multiple people will be able to have accounts with the same names and email addresses and if they go to a different device they will have to create the account over again. I can check your files later when I have some more time to see why they are not working as expected. Files running from the desktop usually have more restricted security settings so that may be an issue.
  17. Nobody was recommending books or websites, this looks like a pre-written response being mass posted on a lot of different forums for the purpose of advertising.
  18. The list is already ordered, you would only need to specify the type if the type itself really matters. By default it's numbers and most of the time that's good enough.
  19. The flags are wrapped in <div> tags, so they're blocks and force adjacent content to the next line. It's easy to fix. All of these divs have a class "svg-flag", so you can just display them as inline blocks. You can add vertical-align to better align them with the text. .svg-flag { display: inline-block; vertical-align: middle; }
  20. To preface this post, I am not a W3Schools staff member, I am just a forum moderator. My views are personal and don't represent W3schools at all. You probably should see the list of hundreds of well established programming languages that did not make it on W3Schools. W3Schools makes tutorials for languages that people will find useful in their job every day. If Julia becomes a widely adopted language, perhaps a tutorial will be made.
  21. The reason that the script is not working is likely because the "uploads" directory has not yet been created. You can use file_exists() to check if the directory exists yet and if it does not you can use mkdir() to create it. PHP does understand relative paths. The only reason you need to use __DIR__ is if your script is being included in another file or if the current working directory has been changed. The working directory may have been changed with the chdir() function.
  22. Ingolme


    Internet Explorer does not support WAV, other browsers do. If it's just for browser compatibility you can use WAV files if you don't care to support Internet Explorer or Microsoft Edge. As for whether you should use it, I would recommend against it. The files take longer to load for the user and they take up a lot more bandwidth on the user's end. Many people have data caps, so it is a good idea not to waste it unnecessarily.
  23. They work the same, but it preferable to use CSS as mentioned on MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol CSS should be in an external stylesheet rather than in a style attribute.
  24. Ingolme

    Unsecure Website

    You can use an internet address as the src attribute of the iframe and it will work without any problem. If you write HTML between the iframe tags, that won't work. The browser ignores it. I'm referring to code like this: <iframe> <table> <tr> <td>...</td> <td>...</td> <td>...</td> </tr> </table> </iframe> That table gets ignored, the only thing that gets shown in the iframe is whatever is in its src attribute.
  • Create New...