Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. In order for clearTimeout() to work, the timeHandler variable must be accessible. If timeHandler is declared inside the showSlides() function then it can only be access from code inside the showSlides() function. You can make timeHandler global by declaring it in the same place that slideIndex is declared, then it will be accessible from any of the functions.
  2. I believe the result would not be predictable and the outcome will depend on which of the two stylesheets is loaded first. They may have different base styles for regular elements and there are a lot of !important rules. Overall, whether it works or not depends on whether you like how the two merge together. The class names are mostly different, with W3.CSS having their classes prefixed with "w3-" so I don't think there would be conflicts there. Two full CSS frameworks will take twice as long to download and keep the page from rendering for longer.
  3. What does the error message say? Your functions don't return anything, so there's nothing to print out to the system. Use this function instead for testing: public static void main(String args[]) { Test_Final_Caller S1 = new Test_Final_Caller() S1.test_non_final(); }
  4. You should look up the documentation of functions before you use them. Here's the manual for fread(): http://php.net/fread The second parameter is a number indicating how many bytes to read from the file. The rest of the advice I could give you was already presented by justsomeguy.
  5. This is specifically the reason why CSS frameworks are a bad idea. It litters the HTML with presentation markup. If you can't remove the dependency from W3.CSS then I recommend just copying the rules you need into your own stylesheet which overrides the other one.
  6. I don't see where the contradiction is. Function declarations are not executable, so they don't need to end with a semi-colon.
  7. W3Schools may be wrong. I don't see any restriction on element names in the XML specification: https://www.w3.org/TR/REC-xml/#NT-Name Update: It seems there is a description here: https://www.w3.org/TR/REC-xml/#NT-S This means that it's recommended that you don't use it for custom elements, but it's not technically invalid. If a future version of XML appears using <xml> tags for system reasons your XML document may behave incorrectly, that's the only drawback of naming your elements with "xml".
  8. You're not adding the checkbox values to the message body. Instead of echo $value you should append $value to the message body. You have to properly indent your code. It's unreadable. Here are the rules: "Level of indentation" refers to either one tab or a fixed number of spaces. Multply the level of indentation by the number of spaces or tabs you have chosen as your indentation width and put it preceding the line of code. The first line of your code must have no indentation, level zero. Whenever you have an opening curly brace "{" you add one level of indentation on the lines that follow Whenever you have a closing curly brace "}" you remove one level of indentation on that line and all the lines that follow Closing curly braces "}" must go on their own line.
  9. For listening, you can use the HTML <audio> element. If you want to customize its appearance you will need to generate HTML elements for the controls and add click events to call methods from the HTMLMediaElement interface. For downloading, a direct link to the file works. If you want to force a download you will need a PHP script that sets a Content-Disposition header and then you would link to that script. Here's a basic example, but you might want to adapt it to your specifications: <?php $song = 'mysong.mp3'; header('Content-Type: application/octet-stream'); header("Content-Disposition: attachment;filename=$song"); echo file_get_contents("files/audio/$song"); exit; ?>
  10. Create is a loose term. You're creating an animation. Everything on the canvas has to be done with programming. There is no drag and drop tool for it.
  11. Assuming the form was submitted properly, the value from the dropdown will be in one of the elements in $_POST or $_GET. You could assign it to a variable or use it directly. You should use prepared statements for your queries. Here's the tutorial page for prepared statements: http://www.w3schools.com/php/php_mysql_prepared_statements.asp
  12. The first one is a method that belongs to another object. When a function is declared like this: var f = function() {}; The function is only accessible in the lines of code following that function declaration. When declared like this: function f() {} The function can be accessed from code that's written before it was declared.
  13. Null is usually the value you assign to a variable if it's meant to contain an object but does not have one yet. You can set a variable to null in order to remove a reference to an object and free memory.
  14. It's not really a bug, it's actually designed that way in the specification: http://www.ecma-international.org/ecma-262/5.1/#sec-11.4.3 My first recommendation would be to not use the typeof operator. You might think you need it, but there probably is a better way to design your software. If you show me the code where you need it I can find out how to write the code without it.
  15. self is also an object. sprites is a property of self that also contains an object. You cannot use var to set properties. Objects can contain other objects and arrays as properties. var a = {}; // This is an object a.b = { // Property "b" is an object that contains a property "c" which is also an object c : {} }; a.b.c.d = "Value"; // Object "c" has a property called "d" with a string as its value.
  16. It's complaining about bad indentation. You're opening the function at one level of indentation but closing it at a different level. Almost all the lines in your code have bad indentation. Here's an example: Your code: function openModalSearch() { 'use strict'; var modalSearch = document.getElementById("modal-search-container"); modalSearch.style.height = "100%"; } Proper indentation: function openModalSearch() { 'use strict'; var modalSearch = document.getElementById("modal-search-container"); modalSearch.style.height = "100%"; } You also forgot to end the 'use strict' line with a semi-colon here: function showSearch(){ 'use strict' // NEEDS SEMI-COLON document.getElementById("search-container").style.visibility = "visible"; }
  17. The line break between "hello all" and the opening <script> tag is rendered as a space. In HTML spaces, tabs and line breaks render as a single space. Content between script tags is not rendered.
  18. When there is a syntax error in a file, none of the code in that file gets executed, including the timezone code.
  19. Unlike flash, canvas does not provide a user interface to create things. You have to build it all with code.
  20. That's an object. It's in the Javascript tutorial: http://www.w3schools.com/js/js_objects.asp Objects are used to organize data.
  21. The dictionary data structure might be what you're looking for. It works like this: var dictionary = { "garfield" : "Gimme lasagne!"; }; for(var item in dictionary) { if(dictionary[item] == "Gimme lasagne!") { console.log("\"Gimme lasagne!\" belongs to " + item); break; } } More efficiently, you can reverse the values, but they have to all be unique. var dictionary = { "Gimme lasagne!" : "garfield", "Something" : "person" }; if(dictionary["Gimme lasagne!"]) { console.log("\"Gimme lasagne!\" belongs to + dictionary["Gimme lasagne!"]) }
  22. The first thing I would check is what version of PHP you're running. Edit: It looks like there's a note in the manual http://php.net/chroot
  23. All that line of code does is point to an element on the page. game.scores.totalScore just tells the program in which HTML element the score should be written. The value you're looking for is not in game.scores.totalScore. The actual values are stored in these variables: // Counters var totalScore = 0; var totalShots = 0; var oops = 0; var hits = 0;
  24. The solution to make something close when clicking anywhere on the page is to add an event listener to the body. We can take advantage of the event target to make sure that the menu only closes if you click on something that is not the menu. document.body.addEventListener("click", closeMenu, false); var menu = document.getElementbyId("my-menu"); function closeMenu(e) { var element = e.target; // This is the element that was clicked on // Make sure that none of the ancestors is the menu var foundMenu = false; while(element && !foundMenu) { if(element == menu) { // The menu was clicked on foundMenu = true; } element = element.parentNode; } // Close the menu if we didn't click on it if(!foundMenu) { // Hide menu // // } }
  25. That's the HTML element in which the score is displayed. Do you know what getElementById() is?
×
×
  • Create New...