Jump to content

Ingolme

Moderator
  • Posts

    14,633
  • Joined

  • Last visited

  • Days Won

    135

Ingolme last won the day on October 24

Ingolme had the most liked content!

Previous Fields

  • Languages
    C++, Java, PHP, SQL, Javascript, CSS, HTML

Contact Methods

  • Website URL
    https://www.thecodingfox.com/

Profile Information

  • Interests
    Software development, videogames

Recent Profile Visitors

192,779 profile views

Ingolme's Achievements

w3schools Guru

w3schools Guru (7/7)

1.1k

Reputation

  1. It looks like the links are generated using a content management system like Drupal, so I don't think they have a way to change the HTML directly. Ideally, it would be best alter the content management system to generate the links with the correct text. How this is done depends on what CMS you're using and how you're using it. If that's not an option, then you could use Javascript to loop through links and edit the text for each one of them. You will have to specify what text you want for each link, which I've done with an object. function editLinks() { // THe left indicates the current value and the right indicates what we want to change it to var replacements = { "http://example.com" : "Visit Website 1", "https://example.com" : "Visit Website 1", "http://example2.com" : "Visit Website 2", "https://example2.com" : "Visit Website 2" }; // Loop through every link on th page. // If you have more information, you can select a smaller range of links to test. var links = document.getElementsByTagName("a"); for(let i = 0; i < links.length; i++) { let link = links[i]; // If a replacement was found then change the link text if(replacements[link.text]) { link.text = replacements[link.text]; } } } // The above function should start running when the page has finished loading. window.addEventListener("DOMContentLoaded", editLinks);
  2. It's not easy and Javascript alone wouldn't be able to do it. You need a server-side language and a database or access to an API. There are two possible approaches: Get the country from the user's IP address by using an IP address database or API. This can only be done by a server-side language. Get the user's coordinates with the geolocation API and use a database or API to determine which country the coordinates belong to. Both of these would take a few hours of work to complete, so it's not something I can write in a forum post. If you want to avoid this complication, the best solution is to ask the user what country they're in, using a dropdown or an autcomplete text field.
  3. The child selector ">" selects children of anything on the left which match the selector on the right. I only mentioned <div class="grid-container"> because it was the only element in your example code that matches the selector, but it doesn't mean that it needs to be a div. To be more precise, the previous code would work on <div> elements which are children of any element with class="grid-container"
  4. The class names were probably given so that you can change the code and try styling the other elements for practice. Even if that weren't the case, it's good to treat all of the elements equally because you don't know if you'll want to style different elements in the future when redesigning your website.
  5. It selects <div> elements which are immediate children of <div class="grid-container". Which means that it selects <div class="item1">, <div class="item2">, <div class="item3">... etc. because they are the children of <div class="grid-container">
  6. The divs with class "myDIV" are still being displayed as blocks. You need to make those into inline elements as well.
  7. If you don't want the <div> to have an effect on the page flow, you can make it an inline element instead of a block using CSS. .myDIV:hover + .hide { display: inline; color: red; }
  8. You're allowed to put an <img> tag inside the <div class="hide"> element.
  9. Chrome probably also has this security feature built in. All browsers should, though I haven't tested them all to make sure. If you want to test AJAX you need to set up a web server, it doesn't have to be on a web host, you can create a small testing environment on your own computer by using XAMPP.
  10. There are only two possible scenarios where the variables are not displayed on that page: You haven't yet visited the page that gives the variables a value. Your browser is blocking the session cookie. If you use private mode in your browsers, that might be the reason that cookies are being blocked.
  11. You have to do more than just change the value from false to true. With asynchronous requests, the code which uses the response data needs to go in a callback function. This function needs to run when the onload event fires. W3Schools has an asynchronous example with a callback function here: https://www.w3schools.com/js/tryit.asp?filename=tryjs_ajax_get If you're running code from your filesystem, Firefox will block all AJAX requests for security. AJAX needs to be tested on a web server.
  12. Unfortunately, there is no way to do that in standard SQL, but it really won't take longer than 5 minutes to write the query even if the table has 100 columns.
  13. The code looks correct and it is working properly in Firefox on my device. I first opened this page to write values to the session: https://tryphp.w3schools.com/showphp.php?filename=demo_session1 Then I opened this page and can see the correct values: https://tryphp.w3schools.com/showphp.php?filename=demo_session2 If the problem is happening with the code on your web server then show your code here and maybe I can find out why it's not working.
  14. The only way is to do a null test on every column in the table. SELECT * FROM table_name WHERE column1 IS NULL OR column2 IS NULL OR column3 IS NULL OR column4 IS NULL I can't think of any practical use case where I'd want to test for null in all columns.
  15. Javascript does not have any kind of command which stops the program until something has been completed. It is asychronous, the program continues running while callback functions are called when specific events occur. For this reason, anything you want to wait for has to be in a callback function. When the program starts, it runs the queries. For each query it adds 1 to a counter (numQueries) to indicate that the query is now running. Each query has a callback function that runs once the query has completed. This callback function stores the results of the query in a global variable for later use and then calls the handleResults() function. The handleResults() function subtracts 1 from the counter I created earlier to indicate that this query has ended. I seem to have made a mistake though, it should look like this instead: numQueries--; if(numQueries > 0) { return; } If there are still unfinished queries, then the counter will be a value bigger than zero, so we will return from the function and do nothing. Once all the queries have ended, the counter numQueries should be zero, so we know that we can start processing the query results. The results will be stored in the global variable globalResults.
×
×
  • Create New...