Jump to content

Ingolme

Moderator
  • Posts

    14,890
  • Joined

  • Last visited

  • Days Won

    174

Everything posted by Ingolme

  1. Ingolme

    Css hacking

    Unfortunately, the W3Schools staff do not actively participate in the forums. CSS cannot be used to hack, it is not even a programming language. You probably are confusing it with some other unrelated technology. CSS is just a way to set the font, colors and positions of things on a website in a browser like Chrome or Safari.
  2. Ingolme

    python

    Regular expressions are usually used to validate strings. If you want to verify that a string is an email address, a regular expression like (.+)@(.+) is a very simple way to do it.
  3. The required attribute of the field causes the browser to automatically check whether the field has been filled in.
  4. No, just update the keys of the data array to be the same as the placeholders. There is some information about PDO placeholders on this page: https://www.w3schools.com/php/php_mysql_prepared_statements.asp
  5. The keys in your array don't match the placeholders in the SQL query.
  6. If you make an SVG image file with that shape and gradient you can use it as a background image for your div.
  7. The HTTP status (requestObject.status) will usually provide some useful information. It will provide a number returning one of the codes listed on this page: https://www.w3schools.com/tags/ref_httpmessages.asp If the user's internet was offline at the time, the status code would be zero.
  8. What I mean to say is that an experienced programmer would have to spend weeks writing the code. There is not a short piece of code which can be posted on a forum.
  9. This sounds very complicated. It could take weeks of research if this were one of my projects. In summary, there's no simple piece of code you can copy and paste, it requires a certain depth of knowledge.
  10. You can use the cURL library to request data from any server. This example comes from the PHP manual page for curl_exec(): <?php // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); ?>
  11. For security reasons, Javascript is not able to read files on a different domain than the one that the page is on unless the owner of the domain sends an HTTP header allowing it.
  12. Try sending an email to help@w3schools.com to see if they can help solve the problem. The website staff are not active on the forums.
  13. It would be helpful to learn Javascript instead of copying code, because the change is not very difficult to do if you know Javascript. You just have to loop through the table cells in a row instead of selecting just one of them: // Declare variables var input, filter, table, tr, tds, td, i, j, txtValue, found; input = document.getElementById("myInput"); filter = input.value.toUpperCase(); table = document.getElementById("myTable"); tr = table.getElementsByTagName("tr"); // Loop through all table rows, and hide those who don't match the search query for (i = 0; i < tr.length; i++) { tds = tr[i].getElementsByTagName("td"); // Determine if the value was found in any of the cells found = false; for(j = 0; j < tds.length; j++) { td = tds[j]; txtValue = td.textContent || td.innerText; found = txtValue.toUpperCase().indexOf(filter) > -1; if(found) break; } // Update the row if the value was found if(found) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } }
  14. I don't see anything obviously wrong with the code. Does the text file exist in the same folder as your PHP file?
  15. You should omit the domain altogether. Preceding a path with a slash will make it relative to the website's root: <a href="/things"> If you need to access your site from a different website you should put it on a public server.
  16. This forum is completely community run, the W3Schools staff do not actively participate here. The members of the forum are random people who just signed up and kindly decided to answer questions. I am just a moderator, I'm not actually part of the W3Schools staff. I used to answer questions more frequently but these days I don't have as much time, so beyond keeping the forums in check I usually only answer shorter questions. I can provide a short answer but it will require some knowledge on your part, otherwise you'll just be blindly copying code which I don't have time to explain in detail. First of all, we can generalize the modal. Instead of an id attribute, use a class attribute. You already have class="modal", so we can work with that. Second, we should get rid of all of the onclick attributes. Events are best handled exclusively by Javascript instead of embedded in the HTML. Finally, remove all id attributes from the system since we want to generalize this. With those steps out of the way, we will use HTML DOM properties and methods to access elements and assign event listeners to them. For the following code, I am assuming that <div class="row"> always directly precedes a <div class="modal"> in your code. If the structure is different then you will need different code to access the elements. // Declare iterators. var i, j; // Go through each row and assign events var rows = document.getElementsByClassName(".row"); var images; for(i = 0; i < rows.length; i++) { // Prepare each image in the row images = rows[i].getElementsByTagName("img"); for(j = 0; j < images.length; j++) { // Use the image's position as its slide number and save it in an attribute images[j].setAttribute("data-number", j); // Assign an event listener to the image images[j].addEventListener("click", openModal); } } // Gather all modal boxes and assign events to the buttons inside var modals = document.querySelector(".modal"); var modal, close, prev, next; for(i = 0; i < modals.length; i++) { modal = modals[i]; // Close button close = modal.querySelector(".close"); close.addEventListener("click", closeModal); // Next button next = modal.querySelector(".next"); next.addEventListener("click", nextSlide); // Prev button prev = modal.querySelector(".prev"); prev.addEventListener("click", prevSlide); } // Declare all the functions function openModal(e) { var image = e.currentTarget; // This assumes the HTML structure is exactly as you posted var modal = image.parentNode.parentNode.nextElementSibling; // Set the display to block modal.style.display = "block"; // Choose a slide if(image.hasAttribute("data-number")) { var slideNum = image.getAttribute("data-number"); showSlide(modal, slideNum); } } function closeModal(e) { var modal = e.currentTarget.parentNode; modal.style.display = "none"; } function nextSlide(e) { // This assumes the HTML structure is exactly as you posted var modal = e.currentTarget.parentNode.parentNode; var num = modal.getAttribute("data-slide"); if(!num) num = 0; num++; showSlide(modal, num); } function prevSlide(e) { // This assumes the HTML structure is exactly as you posted var modal = e.currentTarget.parentNode.parentNode; var num = modal.getAttribute("data-slide"); if(!num) num = 0; num--; showSlide(modal, num); } function showSlide(modal, num) { var slides = modal.getElementsByClassName("mySlides"); var dots = modal.getElementsByClassName("demo"); var captionText = modal.querySelector(".caption p"); if (num >= slides.length) { num = 0 } if (num < 0) {num = slides.length - 1} for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[num].style.display = "block"; dots[num].className += " active"; captionText.innerHTML = dots[num].alt; // Store the current slide in an attribute modal.setAttribute("data-slide", num); } I haven't tested this code, so there might be some typing mistakes. You can use the browsers error console (usually available by pressing F12) to look for errors and try to fix them.
  17. I don't use Python much, but it looks like it should work just fine. The variable M is available and can be passed into the range() function, so there should be no problem.
  18. Unfortunately, you can only remove listeners is you have access to the function which was assigned as the event handler. This "tippy" library, if it was built properly, must have some methods to remove tooltips. If not, then your only hope is to recreate the element and delete the old one. // Get the old element var old = document.getElementById("tippy_test"); // Create a new element var replacement = document.createElement("div"); replacement.id = "tippy_test"; replacement.innerHTML = old.innerHTML; // Replace the old element with the new one old.parentNode.insertBefore(replacement, old); old.parentNode.removeChild(old);
  19. Try sending an email to help@w3schools.com to see if the site staff can help you. They don't interact with the forums, so nobody will be able to help you here.
  20. It seems your conditions weren't correct. This is how the collision condition should be tested: if ((mybottom < othertop) || (mytop > otherbottom) || (myright < otherleft) || (myleft > otherright)) {
  21. It might be because the schema file is using a link to your local filesystem instead of a server. That is the extent of my knowledge.
  22. MDN has a good description of image formats and what they're good for: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#supported_image_formats Personally, I find PNG to be the most reliable format for complex images. While WebP has slightly better compression, it is not as widely supported by browsers, though all the biggest browsers support it. SVG is good for simple shapes, since it is a vector format. It is ideal for icons, logos and similar images.
  23. Oh, I see you were referring to the website account rather than the forum account. I'm afraid I cannot really help, but you can send an e-mail to help@w3schools.com to see if they can resolve your issue.
  24. You could try using break-inside. If the break-inside rule does not work on the <img> tag then it might not be possible to solve this.
  25. There is information about centering containers on this page: https://www.w3schools.com/howto/howto_css_center_website.asp I recommend upgrading from XHTML Transitional to HTML 5. XHTML was phased out ten years ago.
×
×
  • Create New...