Jump to content


Popular Content

Showing most liked content since 03/22/2018 in Posts

  1. 1 point
    <?php $stove=""; if(isset($_POST['stove'])){ $stove=$_POST['stove']; }
  2. 1 point
  3. 1 point
    The OR operator in Javascript returns the leftmost operand that evaluates to a boolean true value. In the following code, the variable x gets set to 5 because 0 is false. var x = 0 || 5; When you assign a variable to itself nothing changes: var x = x; When a variable does not exist, its value is undefined which evaluates to boolean false. In the following code the variable x gets set to 5 because an undefined variable is false. var x = x || 5; In conclusion, the code var x = x || []; will do nothing when x already exists but will assign an empty array to x if it does not already exist. The reason that people creating embeddable scripts do this is to prevent the program from breaking when somebody embeds their code more than once in the same document.
  4. 1 point
    It's not correct. Asynchronous is not about the order of execution, that is merely a side effect, but about whether or not the browser should halt loading the page when it comes across a script. HTML just tells the browser what scripts to load and how to load them. As for methods of loading Javascript, there are just two: synchronous and asynchronous. When a script is synchronous, the page stops loading at the point where the <script> tag ended, waits for the entire script to download, then runs the Javascript from the file, then continues loading the rest of the HTML. This really slows down the page from loading which is why it is recommended to have script tags at the bottom of the document or to load them asynchronously. If you load scripts synchronously in the <head> section then the page will be blank until the scripts are done downloading. When a script is loaded asynchronously, the page begins downloading the scripts but continues parsing the rest of the HTML on the page, waiting until the script has finished downloading before running it. The problem with this is that you cannot predict the order in which scripts will run: whichever script downloads the fastest runs first. The defer attribute tells the browser to remember the order in which scripts were in the document, but this behavior is only predictable if all script tags have the defer attribute and not just some of them. Most of the time, the defer attribute is not used for that purpose and instead is just used to be backwards compatible with old versions of Internet Explorer because it does not support the async attribute.
  5. 1 point
    In the first example, if you change a, b will also change because they're both pointing to the same thing. In the second example, both a and b can be changed independently of each other because they're two different arrays that merely have identical content.
  6. 1 point
    w3.js was a good and simple framework for easy functions. It could be popular one in future with more extended development. Why W3schools dropped it? Appml was another effort by W3schools but it was little complicated and also deprecated shortly without any prior notice. I was very much interested about w3js and started using it rather than angular. So please re-link the w3js and make it better by future development.
  7. 1 point
    The use of both async and defer is often done because old versions of Internet Explorer only understood the defer attribute. They're not mutually exclusive, async tells the browser to continue loading the rest of the page while the script is being downloaded. The defer attribute works the same, but deferred scripts are executed in the same order as they are in the DOM rather than executing each one the moment they finished downloading. The async and defer properties are explained in detail on this page: https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement In short, x.parentNode.insertBefore(y, x) means to put y right before x in the document. It doesn't matter what or where x or y are as long as they're both DOM nodes. The insertBefore method works like appendChild(), but instead of putting it at the end of the children, it specifies one of the existing children of the node before which the new element should be inserted. W3Schools has a page explaining the insertBefore() method here: https://www.w3schools.com/jsref/met_node_insertbefore.asp
  8. 1 point
    The problem is in the function name 'strpos' being at the beginning, the position will be 0, so 0 will be treated as false. The position of needle text placed anywhere but the beginning will be greater than 0, meaning true. You need to check against not being false within the if condition and make sure you use !== compared to != with single equals symbol. http://php.net/manual/en/function.strpos.php
  9. 1 point
    No, that adds a new item to the array. The new item is an array with 1 item in it, "trackPageView". So, if _paq was an empty array, then _paq[0][0] would be "trackPageView". trackPageView is a value, not a key. Those are both values, not keys. That is an array with 2 values being added to _paq. Values listed in an array are separated by commas. Technically, Javascript does not have arrays with string keys, all array keys are numeric. But since everything in Javascript is technically an object, even an array, then you can represent an array as an object structure where the property names are strings. You can refer to those using either array or object syntax. No, that's getting the first script tag on the page, so it assumes there's at least one. getElementsByTagName returns a collection of elements, so it's getting the first element in that collection. Later it uses that script element as the reference to insert the new one. It would look like this: <script type="text/javascript" async="true" defer="true" src="value_of_variable_u/piwik.js"></script> Note that the entire function expression needs to be wrapped in parentheses: (function expression)();
  10. 1 point
    A responsive line? tried a hr element https://www.w3schools.com/code/tryit.asp?filename=FQ3IJ9HRC2XE
  11. 1 point
    To make it clear on what is happening, the function within the load() is triggered after the content is loaded and load() function finished. That is why you didn't see the result you expected, the load() function was still in progress, when the scroll to top code was triggered.
  12. 1 point
    Just to make it clear to some of those watching! This has everything to do with the code. <script> $(document).ready(function() { $('.pmbutton').click(function(e) { $('.mail_text').load('scripts/message.php', {id: $(this).data('id'), id2: $(this).data('id2')}, function() { var objDiv = document.getElementById("mail_text"); objDiv.scrollTop = objDiv.scrollHeight; }); }); }); </script>
  13. 1 point
    You can put a <script> tag with a src attribute preceding your code. Some people like to use Javascript to generate script tags, but if you can just write the HTML for it I find that to be a better solution. <script src="arrays.js"></script> <script> This code uses the array </script>
  14. 1 point
    IS this supposed to be a horizontal or vertical menu? First : The br elements are not valid and not allowed as child of ul, remove them IF you want this as a vertical menu, remove float: left;, from LI elements and change to display: block; IF you want horizontal removing the BR element will fix this, as the float: left; property will give you the horizontal li that you require.
  15. 1 point
    IF $mainRow represents a single variable value then $uniqueValueArray = []; // this is now the normal way of declaring a array variable since PHP 5.4 while ($stmt->fetch()) { if (!in_array($mainRow, $uniqueValueArray)) { $uniqueValueArray[] = $mainRow; } } // END while ($stmt->fetch()) echo implode(', ', $uniqueValueArray);
  16. 1 point
    The clue is in the method name 'document.getElementById()'. None of those radio button has a id ref, and it would be impractical to use that anyway, The options are to use getElementsByName("guess") and loop through them all, identify which is checked and retrieve that elements value. function test() { var myinput = document.getElementsByName("guess"); for (i = 0; i < myinput.length; i++) { if (myinput[i].checked) { document.getElementById("answer").value = myinput[i].value; } } } OR use the newer 'document.querySelectorAll()' function test() { var myinput = document.querySelectorAll('input[name="guess"]:checked')[0]; document.getElementById("answer").value = myinput.value; }
  17. 1 point
    It is there, but hidden. If you wish to hide the login/register part it has a class for it parent ul element, so you can use .alt-mobile-menu { display: none; }
  18. 1 point
    Array indices start at zero, not one. If an array has two elements you access them as $row[0] and $row[1], not $row[1] and $row[2]. The error happens because $row[2] does not exist.
  19. 1 point
    Whatever the predefined variable value is at the time php code refers to that variable is what is used. if $result refers to $sql variable the value will be and show 'select * from users', if the $result was after the last $sql, this last $sql overwrites the previous variable to show "select * from stars". If that is what you are asking?
  20. 1 point
    Unless you are going to use the value of state from dropdown somewhere else, you can simply change the value from dropdown to the actual country that the text state of options is showing. You then wouldn't require any arrays just the retrieved value from selected state.
  21. 1 point
    It's a short form of scientific notation used in floating point numbers. The e represents 10 elevated to the number that follows it. 5e6 is the same as 5 * 106 or 5 * 1,000,000 = 5,000,000