Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. The idea of a view-model is a slight alteration to the ordinary Model-View-Controller paradigm. First of all, to make things clear, there's no solid definition for what MVC is, it's just the idea of dedicating one of three different functions to each piece of your software. In the paradigms that contain a view-model component (I've seen the Model-View-ViewModel paradigm mentioned before), a view-model is a model that is attached to a view in such a way that an alteration to the model directly alters the view that it is connected to without the need for a controller to read the model and pass the data to the view.
  2. My guess is that the person who made the quiz considered "comment" and "multi-line comment" two different things, with "comment" only referring to the single-line comment. That seems to be the way it is represented in this chapter: https://www.w3schools.com/java/java_comments.asp
  3. It depends on the layout of your page. The link should align the top of the element with the top of the window. You might have more than one element with the same ID or CSS is causing the top of the element to be further down than its visible content.
  4. You probably should check the security settings of each of your browsers. Whenever the website makes a request for the location, the browser asks the user for permission. If this is not happening it's likely that the browser has been configured to reject all location permission requests. Each browser has its own permission setting, it is not shared across browsers.
  5. Ingolme

    Sean

    You will need to learn a server-side programming language. The easiest one to learn is PHP. Whichever language you choose to learn, it will not be anywhere near as easy as HTML.
  6. There isn't enough code here to determine exactly what the problem is. The code shown here would submit the page to itself and do nothing since there are no fields in the form.
  7. Javascript does not work in HTML includes, you have to load the Javascript sections including the onclick event from their own .js file using <script> tags.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. You only need to make one topic for your question. There are answers in your other topic. I'm closing this one.
  14. It's built using HTML, CSS and Javascript.
  15. 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.
  16. 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.
  17. They don't. There's a "report error" link at the bottom of each page if it has something incorrect or incomplete.
  18. 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.
  19. 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.
  20. 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.
  21. 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.
  22. 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.
  23. 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.
×
×
  • Create New...