Jump to content

Ingolme

Moderator
  • Posts

    14,536
  • Joined

  • Last visited

  • Days Won

    119

Everything posted by Ingolme

  1. Those characters would be something like left arrows and right arrows. Your document's character set has not been specified. You need to do two things: In your code editor, make sure that the character encoding is set to UTF-8 before saving the HTML file. Add a <meta> tag in the <head> indicating which character encoding is being used in the document like the following: <meta charset="UTF-8">
  2. The information you pass to the send() method of the XMLHttpRequest object is just a string. The Javascript variable "data" does not exist in the HTTP request, it just holds the string "Test String" temporarily on the client side. The variable name "data" has to be included as part of the body of the request, like this: xhr.send("data=Test String");
  3. Spaces are important in HTTP requests. You've sent this to the server: "?d = data", so that key would be "d " and the value would be " data" If you remove the spaces it should work. It would be better to use $_GET than $_REQUEST to make it clear where the information is meant to come from. $_REQUEST also searches for data in POST data and cookies.
  4. The value of top has to be a number, it cannot be "absolute". "absolute" should be the value of the position property. The element which wraps around the overlay should have a relative position. I cut out some superfluous elements and changed some of the code back to what it was in the original W3Schools examples: https://www.w3schools.com/code/tryit.asp?filename=GSU8T8H7Z2IN
  5. It seems that W3Schools does not explain how to set up and use Python on the server-side, maybe because it is very common for people to use Python for programming on their PC rather than as a server-side programming language. I don't use Python myself, so I can't tell you how it works. This page seems to have some explanations: https://pythonbasics.org/webserver/
  6. There are only a few people on the forums and they all would have seen your topic by now. I don't think tags are going to change anything, but I can add them to the topic if you want.
  7. I've never made an app for Android so I can't answer that. If I intended to build an app, I would download Android Studio and build it there.
  8. Regarding answers to your topics, this is a forum where ordinary people sign up to ask or answer questions. The W3Schools staff are not actually directly involved, answers come from regular users like you. If nobody knows the answer to your question you may not get any answers.
  9. The reason you're finding code that prints all of the terms up to N is because that is what a progression is: a sequence of terms. Math.pow() already provides everything you need to find any one term in a geometric progression, which is why browsers will never implement a more specific function to do it. If browsers had a dedicated built-in function for every single little problem somebody wanted to solve there would be millions of them. The formula for a term is right on the page you linked to: TN = a1 * r(n-1) The code is simple: function geometricProgression(a1, r, n) { return a1 * Math.pow(r, n-1); } Putting into the HTML with the inputs and outputs it would look like this: Progression factor: <input type="number" id="factor" value="2"><br> Term number: <input type="number" id="term" value="1"> <button onclick="myExample()">Convert</button> <p id="exmpone1"></p> <script> function myExample() { var factor = Number(document.getElementById("factor").value); var term = Number(document.getElementById("term").value); document.getElementById("exmpone1").innerHTML = geometricProgression(factor, factor, term); } function geometricProgression(a1, r, n) { return a1 * Math.pow(r, n-1); } </script>
  10. Your initial array is already sorted. Try changing the numbers to be out of order.
  11. The value stored in i is still less than 6, you are just printing numbers larger than 6 without changing the value of i.
  12. You can use the attribute ^= selector on the class attribute. It would look something like this: [class^="col-"]. Though this will only match elements where the first class in the attribute begins with "col", it would not match <div class="something col-sm-4"> because the attribute starts with "something".
  13. There is no way for the server to predict what a computer's next IP address will be, so I can't think of any way it could work. If you happen to have a list of all the IP addresses that may be assigned to the computer you could allow all of them.
  14. Those are bitwise assignment operators. They perform a bitwise operation and then assign the result to a variable. It looks like the W3Schools Java tutorial does not have any information about how bitwise operators work, probably because it is difficult to explain in simple terms. Bitwise operators treat whole numbers as sequences of 1s and 0s. Each 1 or 0 is called a bit. There are several operations you can do with bits, which are mostly similar to the logical operators. There is & (and), | (or), ~ (not), ^ (exclusive or), << (shift left) and >> (shift right). The sequences of 1s and 0s are called binary representations of the numbers. For example, 5 in binary is 101 and 3 in binary is 011. & operator Decimal: 5 & 3 = 1 Binary: 101 & 011 = 001 | operator Decimal: 5 | 3 = 7 Binary: 101 | 011 = 111 ~ operator (Since integers have 32 or 64 bits, and all the zeroes need to be taken into account, and computers treat large binary numbers beginning with 1 as negative, this one is actually more complicated to describe) Decimal: ~5 = -6 Binary: ~00000000000000000000000000000101 = 11111111111111111111111111111010 ^ operator Decimal: 5 ^ 3 = 6 Binary: 101 ^ 011 = 110 << operator Moves bits a certain number of positions to the left (This is equivalent to dividing by 2 a number of times and removing any decimal part from the result) Decimal: 5 << 2 = 20 Binary: 101 << 2 = 10100 >> operator Moves bits a certain number of positions to the right (This is equivalent to multiplying a number by 2 a number of times) Decimal: 5 >> 2 = 1 Binary: 101 >> 2 = 001
  15. PHP and Javascript operate in two completely different environments. PHP generates Javascript code and Javascript is unaware that PHP was running at all. You could even write something this and it could potentially generate usable Javascript: var <?php echo $_SESSION['varname'] ?> = "Hello World!"; In order to have Javascript treat something as a string, it has to be wrapped in quotation marks. On PHP's end, you'll want to escape any quotation marks that are in the string itself. A working example should look something like this: var s = "<?php echo addslashes($_SESSION['subscriptionid']); ?>";
  16. Javascript has a feature where you can access any object's properties or methods using square brackets and a string inside. window.alert() is the same as window["alert"](). myClass.value is the same as myClass["value"]. Since the square bracket notation uses a string instead of an identifier, you can put a variable containing a string within the square brackets.
  17. I think it should work if you use strings instead. Selecting methods dynamically is going to be pretty confusing to anybody who has to maintain your code. I think it's a practice which should be avoided. ... ... constructor(){ this.config = { "branch": "branchA" }; this.classVar = {"a":1} } main(){ this.classVar["b"] = 2; this.branchB(); this[this.config.branch](); } ... ... var myClass = new MyClass(); myClass.main(); myClass.config.branch = "branchB"; myClass.main();
  18. I have removed the code from your previous post. When posting code, don't post more than around 20 lines because anything more and nobody is going to want to read all of it. You must only post the few lines of code that are related to the particular problem you are trying to solve.
  19. You have defined a function, but are not calling it. The code in a function only runs when the function is called. See the "function invocation" section in the Javascript tutorial: https://www.w3schools.com/js/js_functions.asp
  20. Did the tutorials and videos use Visual Studio Code or Visual Studio? Video Studio Code is just a basic code editor, Visual Studio is an IDE (Integrated Development Environment) designed to manage software projects.
  21. Adding to my previous post, it looks like browsers are fast enough to process pixel data of videos after all, as in the example shown here: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Manipulating_video_using_canvas
  22. You probably would have to do the math yourself for each pixel and draw the result on a canvas. I don't think that would run fast enough to work on videos. There is nothing natively in Javascript or HTML that converts between RGB and HSL colors that I am aware of. To run algorithms on individual pixels, I would use getImageData() and putImageData() to do pixel manipulation.
  23. Unfortunately, I cannot allow you to link to your website here. Can you describe the issue and show the code which is causing it? I did not see any responsive issues on your website.
  24. backgroundColor needs a capitalized C. IDs are not permitted to begin with a number, but I think browsers might still work if you do that. I would recommend fixing the ID anyway.
  25. You're probably looking for the value of the element: var eingabe = document.getElementById('meininput').value;
×
×
  • Create New...