Jump to content

Leaderboard


Popular Content

Showing most liked content since 09/17/2017 in Posts

  1. 2 points
    There's nothing formal to tell you things like that. People do it themselves, and it tends to illustrate the Dunning-Kruger effect. People who just recently started tend to rate themselves highly, and only when you get more into something do you realize how much you don't know. I wouldn't put any weight on things like that. If you want to evaluate someone's capabilities look for a portfolio or things they've actually finished.
  2. 1 point
    Yes, you would use an array of objects as shown. As far as file types, it's not very common to have a static file only containing JSON that you read from, they just do that because it's an easy example. It's more likely that you'll be sending ajax requests to PHP or another language on the backend which would dynamically generate the JSON (from a database, as in your example). You can use PHP or whatever language to set the content-type for JSON though, rather than saying it's HTML.
  3. 1 point
    Thank you Gabrielphp, that worked perfectly. I tested for the negative. if(!is_numeric($phonenum1)){ $phonenum1Err="Only numbers0-9"}
  4. 1 point
    You can use a php function called is_numeric(). if(is_numeric($var)) { //do stuff } else { //do other stuff } Hope this is what you want.
  5. 1 point
    The slideIndex will always be 1; When function called var slideIndex = 0; then further on slideIndex++;
  6. 1 point
    If $(this).attr('id') returns the correct ID, then this (and the jQuery-wrapped $(this)) refer to the same element. There's no reason to get the ID from the element, then get the element again. You already have it, you're getting the ID from it.
  7. 1 point
    You could also use $(this) to refer to each element, instead of getting the ID of $(this) and then looking up the same element.
  8. 1 point
    You're telling to find an element with the ID "podType". If you want to use the value of the variable, you need to specify that. $('#' + podType)
  9. 1 point
    1) Anything using below class will use pointing finger cursor .style1 { font-family: Verdana; font-size: 10pt; text-align:justify; cursor:pointer; } 2) You said Which means you would have to apply this styling class name to container element, which would either be a Paragraph, or Anchor, or Strong element that surround the text ' Click to Read More'. BUT! you have applied class name to This is outside the scope of what you are trying to target, its scope starts from opening span <span class="style1"> and finishes at </span>, all the text "W3Schools is a popular web site for learning web technologies online.[2] Content includes tutorials and references relating to..." will have the pointer cursor, but anything outside this will work as default styling, which is what is happening to anchor text you are attempting to target, because its outside '<span class="style1">....</span>' scope.
  10. 1 point
    You wouldn't really say the "and", it's more like an if statement if window.console exists. The reason that works is because logical operators get short-circuited. Since everything in an AND expression needs to be true for the entire thing to be true, if it finds something that is false then it stops evaluating the rest of the expressions and the result is false. Similarly with OR, if it finds any expression that is true then it stops evaluating the rest and the result is true. So in that expression above, if window.console is logically false then it does not try to execute console.log. Note that they just use console.log instead of window.console.log because window is the default global scope. They don't need window on the left side either but I guess put it there to make it more explicit. There's something else a little weird about logical expressions in Javascript. Take this example: var x = 1; var y = 2; var z = 3; var result = (x && y && z && (x+y+z)); What do you think result is going to be set to? That expression is a bunch of logical AND operators, so it's going to be set to boolean true, right? Wrong, it's going to be set to 6, the value of the last expression that was evaluated. You can use that with OR to have a variable set to the first thing which has a non-falsy value, e.g.: var ajax_object = which || of || these || exists; That can be shorter than writing a bunch of if/else statements, but it only works if things like false, zero, or the empty string are not possible values for those variables.
  11. 1 point
    You have to build it or hire somebody to build it for you. A PHP script will work if your server supports PHP, but there are tons of other server-side languages with which to build your website.
  12. 1 point
    You're going to need software on your server to do anything. HTML does not do anything on its own.
  13. 1 point
    The issue isn't the location of the files relative to each other, it's how you're accessing them. If the URL bar in your browser starts with http:// or https:// then your browser uses one security model, if it starts with file:// or anything like that it uses another. I don't know if ajax even really works for non-HTTP requests, because part of that process is communication with a web server. It might work, but I wouldn't count on it. If you want to download a server for testing, the easiest are packages like XAMPP. That includes the Apache web server, and also PHP and MySQL and some other tools pre-configured. After you install that and start Apache, you'll be able to access it at http://localhost/ There will be a specific folder on your computer that Apache uses as the document root, that's where the root level of your website is. So if you create a file and save it in that folder as index.html, you can access it at http://localhost/index.html, or if you put a folder called images in the document root then that will be at http://localhost/images/ etc
  14. 1 point
    What you're asking for is called pagination and it's usually done by adding a page or offset number to the query string and putting that value into the LIMIT clause of the SQL query. You can use AJAX to do it, but I'd recommend first using just PHP and then adding the Javascript layer on top of that for convenience.
  15. 1 point
    That is mainly done by using JavaScript https://www.w3schools.com/howto/howto_js_slideshow.asp but you may need to ask permission before using another sites images first.
  16. 1 point
    Only 'get' request uses querystring, the passing of 'post' data is hidden and not shown in the address bar.
  17. 1 point
    You should sanitize for any request $_GET, $_POST (data from forms) or $_REQUEST, any of these can be used to insert code. Check out exploits section of https://www.w3schools.com/PhP/php_form_validation.asp
  18. 1 point
    What does that mean? How are you opening it? Are you just double-clicking on a file on your computer or something? If so, the PHP code won't run at all. Or, if it's actually on a web server, then there's always a request. The server responds to requests, that's its job.
  19. 1 point
    The page is reloaded because you are clicking a link which will call itself because no other url is requested, but! the current page url will have the querystring attached to it as well. When the page reloads if this page has php code that will check and read the name and value transferred with the querystring using $_GET[], this value can be passed onto a php variable. Yes! you should sanitize, as it is a querystring viewable and editable from address bar. You could prevent page reloading by using JavaScript, then by using AJAX, process the data from external php page and return result.
  20. 1 point
    There's no uncertainty. When you click on a link like that and the browser is building the URL to request, if the link only contains a querystring then the browser will use the current page, add the querystring to it (or replace an existing one), and use that as the URL for the request. There's honestly not a lot to say on this topic, it's pretty basic. It's just a link to the current page with a new querystring. It wouldn't matter whether or not someone managed to actually create a file with that name on the server because the browser wouldn't request that file anyway, it's going to request the current page again.
  21. 1 point
    Thank you so much - I understand it now after finally putting all the pieces together. I also figured out (from the link you provided) that the pattern string has to be enclosed by a delimiter, thus the two "/". Then the ending "i" mean case-insensitive alpha match. Just for anyone else that reads this post... It looks to me like someone could specialize just in regex coding! Thanks again.
  22. 1 point
    It's fine to use that style to refer to the current page. PHP's magic constants wouldn't help though, there's not one that refers to the current URL. You can build the URL from the $_SERVER array, but it's not necessary if you're just linking to the current page.
  23. 1 point
    The problem with using echo statements is that code editors will not highlight the HTML syntax. If you're building a template file, you usually have large amounts of HTML with small amounts of PHP. I personally do not like the BASIC style syntax even for templates. When you use curly braces, most code editors will show you where the current brace ends and allow you to show or hide the block of code. With proper formatting and indentation the code becomes easier to read. <?php if(isset($_GET['edit'])) { ?> <button type="submit" name="update">update</button> <?php } else { ?> <button type="submit" name="save">save</button> <?php } ?>
  24. 1 point
    Yes! because the chances of it plucking any url or actually landing on a page called ?edit=whatever is pretty substantial.
  25. 1 point
    Just to clarify, if the link is a query string only and does not contain the rest of the URL, it uses the current URL of the page with the new query string.
  26. 1 point
    It should be, it's kind of lazy to leave it out. It should be listed along with the visibility. They don't need to give it a value in that list, they can just specify the visibility.
  27. 1 point
    It doesn't have a plain reading. You use that question mark because it is a query string. From https://www.freeformatter.com/url-parser-query-string-splitter.html What's the 'query string' in a URL? The query contains extra information that is usually in the key-pair format. Each pair is usually separated by an ampersand & character. It follows the ? character. Examples: http://www.foo.bar/image.jpg?height=150&width=100 https://www.secured.com:443/resource.html?id=6e8bc430-9c3a-11d9-9669-0800200c9a66#some-heade
  28. 1 point
    it will reload the page with querystring '?edit=whatever' then php will read this using $_GET['edit']
  29. 1 point
    If you are doing such coding use the : form and not { }, it will be much easier to understand the code when you mix them. <?php if(condition): ?> Html here <?php else: ?> Html here <?php endif; ?>
  30. 1 point
    Echo or escaping and entering by opening/closing php, are both valid, but i think separating php from html is much cleaner as you have it.
  31. 1 point
    Unfortunately this site has no connection with the administrators of w3shools.com, posting this error here, won't receive any attention to fix this error, but I suggest you go to 'About' page on W3schools.com then at bottom of page, click report error link.
  32. 1 point
    That class doesn't seem all that useful, it doesn't provide any protection and really only gives a way to send an array of conditions for a select query. I would suggest using PDO instead, or looking into prepared statements with mysqli and using those. The first error message sounds like the database connection failed.
  33. 1 point
    You are not getting the value, but text content of option list? Every time the loop completes a cycle it overrides the previous html, you need to add to previous, then at the end add to label html var join = ""; $.each(tous, function(index, value) { join += value + "<br>"; //return (value !== ""); ///// why? }); $("#label").html(join); I think this is what you are asking for? As I said, you are using innerHTML not value, so you need to adjust this to your requirements. instead of var l = selectliste.options[selectliste.selectedIndex].innerHTML; you could use var l = $(this).val(); // for value or var l = $(this).text(); // for actual text description
  34. 1 point
    That's because you set it to false right before you alert it. Go back and look at the code I posted, notice how the variable definitions are outside the load handler. They first get defined with those default values, maybe at some point later down the page PHP will redefine them, and then once the page finishes loading the rest of the Javascript runs, using either the default values or the values that were set by PHP.
  35. 1 point
    I haven't tested how jQuery handles that, but I assume that it's only going to execute whatever code was just added to the page. The rest of the code on the page will be executed when the browser gets to that point. I'm referring to the 2 links you posted above. The direct link does not have that link to #60, the "proxy" link does even though they go to the same page. Why, because it's longer? There's nothing unmistakable about 60, as far as the computer is concerned. 60 is also unique and unmistakable. Both 60 and any hash will convert to binary values that are unique, the computer will not confuse them with each other. So they are both values in the same address space of all binary numbers, one of them is just an enormous number but that's the only real difference, they're just numbers. Why would one of them be said to be a quantitatively "better" number than another? Hashes are really only used for one thing - verification. Passwords are stored as hashes and then the hashes are computed to verify that the entered password matches the stored one, or a file might be distributed along with a checksum hash to verify the integrity of the file, that the file you actually saved is the one they distributed, there was no error in transmission. Hashes don't really offer anything as identifiers that you can't get with any other numeric value, and a hash is just a numeric value represented in a different base. One problem I see with using both a hash and an ID is that people cannot find the pages if they only know the ID. If I think you said something great in podcast 60 and I want to share it with someone else, I can't just check the URL and figure out where the ID goes in the URL, I also need to know some long hash that I can't calculate just by knowing that the podcast was number 60. So the only thing I can do is try to find a link to that page somewhere else, I can't just type it in manually. If that's your goal, if you're trying to add some sort of protection against people being able to figure out the URL for any podcast, if you're trying to control access in some way where they need the specific URL and not just the ID, then that would be the result of requiring the hash to be in the URL. Don't think of it like that, PHP and Javascript don't share any values or anything like that, the only relationship is that you're using PHP to output Javascript code. They don't run in the same address space, they don't even run on the same computer (PHP runs on the server, Javascript runs in the browser). As far as PHP is concerned, it's all just text being sent to the browser, PHP doesn't care whether it's Javascript text or HTML text or any other kind, it's just output. So all you have to do is output that Javascript code outside of the element that is being cloned or copied. I can't specifically tell you how to do that, I'm not looking at everything that you are. I assume you have templates or something with all of that stuff in it, so just make sure the Javascript code to copy the content is not part of the content that gets copied.
  36. 1 point
    The act of adding the new HTML content (it does not matter that the content came from somewhere on the page) causes the browser to execute whatever Javascript is in there. The Javascript that is in there tells it to replace the HTML content again, and that keeps happening until the browser gives up. The position of the PHP code is not relevant as far as the browser is concerned, the position of the Javascript code is relevant. Don't put the Javascript code to do the replacement inside the HTML that gets added, it needs to go outside of the element that you're copying. Now, if you need to change the PHP code to get the Javascript code to show up somewhere else, then do what you need to do. I would expect that you only have to change something inside the template though. It's always better to produce the final version the first time, instead of spending time to produce an intermediate version which then needs to spend more time to produce the final version. Redrawing the page in the browser is a fairly expensive process (relatively speaking), it's best to limit how many times you're telling the browser to draw the page. Browsers have gotten a lot better at that over the last decade, but it's still a good practice to try to just produce the final page the first time. That's just how the browser handles it. The HTML on that page is not valid, there's not much point trying to figure out how or why the browser is going to handle invalid HTML when you should just produce valid markup. The first link causes the Javascript loop and error in the console. That link only shows up when clicking from the other page, right? Why do you use a hash, what's the point? If you have the podcast ID shouldn't that be enough to uniquely identify it?
  37. 1 point
    The call stack exceeded error is because you've created an infinite loop, and Javascript quits when the maximum recursion limit has been reached. It's because you have some Javascript code to get the #podcast_insert HTML, and replace the contents of #main with that HTML. The HTML includes the Javascript code to do that replacement, so each time you replace the code it tries to replace it again and again until Javascript hits the recursion limit. The Javascript code to do that should not be inside that div, it shouldn't be part of the content that you're moving. The title tag issue is probably in a template somewhere. If you open the page in your browser and view the page source you can see that tag before the doctype.
  38. 1 point
    Ha, If you change n to x in function, anything referring to n need to be changed to x as well.
  39. 1 point
    You're also trying to loop over n. What's n?
  40. 1 point
    You are prompting for input within the scope of function to x variable, while calling the function with argument outside the scope of function. It will never be able to know the variable x equals.
  41. 1 point
    Using href="#" will have side effects compared to button in that it will reload the page, taking you to top of page with address bar url having '#' at end. You can prevent this using javascript: void() in href OR by passing 'event' as function called argument you can within that function use event with preventDefault() to stop the anchors normal action triggering. https://www.w3schools.com/jsref/event_preventdefault.asp https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_oper_void Display Name is a username? doubt anyone but moderator would have permission to do that, IF allowed.
  42. 1 point
    In its current layout form, you can only make the text fade In, and instantly close , it will take a lot of redesigning of layout to make this work how you want it. https://www.w3schools.com/code/tryit.asp?filename=FJJ9PV6DH1YJ
  43. 1 point
    IF you still want to use console.() to call function with argument, store each value in variable and return THAT final result to console.log function calculate(n) { var results = ""; for (i = 0; i <= n; i++) { var isprime = false; for (j = 2; j <= n; j++) { if (i % j === 0 && i !== j) { isprime = true; } } if (isprime === false) { results += i + "\n"; } } return results; } console.log(calculate(25));
  44. 1 point
    You got undefined because the function is not returning anything. The function must use the return statement.
  45. 1 point
    Where in Brazil?
  46. 1 point
    Hi! My name is Nara. I'm from Yerevan, Armenia. I started to study HTML, CSS for about a month, but I do not feel very good, because I'm 45 ((((. Do you think I have a chance?
  47. 1 point
    SublimeText works best for me
  48. 1 point
    If you posted here, you might find this intersting:http://w3schools.invisionzone.com/index.php?showtopic=456
×