Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. Ingolme

    Tabbed modals

    Each modal has to have its own unique id attribute for this to work.
  2. Ingolme

    RSS Information

    It was merged with the XML tutorial: https://www.w3schools.com/xml/xml_rss.asp
  3. If the link is an article that contains some form of media, then you would use both the link and the enclosure. Let's say there's a link to an article containing the written transcript of a podcast along with embedded audio, you would put the link to that page in the <link> tag and the reference to the audio file in the <enclosure> tag. An RSS item probably should not directly reference a multimedia file, it should reference a web page that contains the file.
  4. Unfortunately, W3Schools does not have any examples of POST requests. Here's an example of sending form data upon submission: // Add a submit event handler to the form var form = document.getElementById("my_form"); form.addEventListener("submit", submitForm, false); function submitForm(e) { // Cancel form submission e.preventDefault(); // Build a query string from the form data var form = e.currentTarget; var query = "", element; for(var i = 0; i < form.elements.length; i++ ) { element = form.elements[i]; if(element.name) { query += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value); query += "&"; } } // Send a request var request = new XMLHttpRequest(); request.onreadystatechange = doSomething; request.open("POST", "file.php", true); request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.send(query); // Form data is here // Handle response here however you want to function doSomething() { if(request.readyState == 4) { if(request.status == 200) { // Success // // } else { // Error // // } } } }
  5. That works but only for an image with solid color, it won't get all the shading. To get the shading you have to multiply the target color with the image's color, but this only works when each color is represented as a value from 0 to 1, so you have to calculate that. This is called a blending algorithm. This one in particular is the multiply algorithm: // Set this to the color you want var newcolor = [ 0xFF, 0, 0 ]; // Convert to unitary value for calculations newcolor[0] = newcolor[0] / 255; newcolor[1] = newcolor[1] / 255; newcolor[2] = newcolor[2] / 255; // For each pixel, multiply the new color with the pixel's existing color var r, g, b; for (var i = 0; i < myImage.data.length; i += 4) { // Get unitary value of the pixel r = myImage.data[i] / 255; g = myImage.data[i+1] / 255; b = myImage.data[i+2] / 255; // Multiply the values and store them myImage.data[i] = Math.floor(255 * r * newcolor[0]); myImage.data[i+1] = Math.floor(255 * r * newcolor[1]); myImage.data[i+2] = Math.floor(255 * r * newcolor[2]); } putImageData() has the drawback of overwriting everything in the rectangular region of the image you're putting it onto including alpha values, this is why I recommend putting it onto its own canvas, then using drawImage() to draw that canvas onto the target canvas.
  6. It looks like canvas doesn't support blending or anything similar. You're going to need multiple different canvas which you then composite using drawImage() First get dats from your source image with getImageData(). Create new image data with createImageData(), then save it onto another canvas using putImageData(). You would pull data from the source image, which should be white with greyscale shading, if it's not white then you can't properly change the color. You would then select a target color. For example, orange (red = 255, green = 120, blue = 0) For every pixel in the source image data, multiply the red component of the source with your target red, green with your target green and blue with target blue. Store those in the destination image data, use the alpha value from the source image. Once that's done, you can use drawImage() to draw this canvas onto a final canvas, properly blending the colors with what's behind them.
  7. Usually the approach to customizable avatar is to have a grayscale version of the object you want to customize and then give it a tint. Using a multiply blend mode with the color works. I'm not sure what options canvas has for tinting and blending, so I would have to check the reference when I have time. In the worst case scenario, create an int array and multiply the color components with the image components, then add it to a canvas using putImageData().
  8. It doesn't look like you copied the function properly. You've given just one argument to the Math.pow() function because of the parentheses. You're using a sine and cosine, though those aren't part of the equation, and the cosine isn't using the right Javascript function for it. You should make this an actual function that can be reused as well. I'd need to see more context to know what all the function constants are for. This is the actual representation of the function Javascript: var xcoord = 0; var ycoord = 100; var smoother = 10; var tipAdjuster = 2.8; function f(x) { smoother * Math.pow(x + xcoord, tipAdjuster) + ycoord; }
  9. It might have something to do with explicitly setting the width of <li> and <a> elements to 100%.
  10. It's not normal to use placeholders to create a database or tables because you don't use user input to create them. The structure is already defined in your software specifications.
  11. Stylesheets don't affect what's inside an iframe. You have to put those styles inside the document that's in the iframe.
  12. Does that work? It depends on what kind of database you're using. Here's a note from the tutorial page:
  13. You're not passing any parameters to the mil() function, it's going to return NaN or undefined. Given what you have currently. this is the shortest way you can put it. The code I provided earlier is more efficient, though. $('#item_encllength').on('mousedown',function() { $(this).val(mil($('#min').val(), $('#sec').val())); });
  14. You just have to set the value of the field. You can't store the value in the variables or it will never update, store a reference to the elements instead. var min = document.getElementById("min"); var sec = document.getElementById("sec"); var encllength = document.getElementById("item_encllength"); encllength.addEventListener("mousedown", function() { encllength.value = ((min.value * 60) + sec.value) * 1000 }, false); If you want it to happen when the form is submitted use the form's submit event instead of the mosuedown event. var min = document.getElementById("min"); var sec = document.getElementById("sec"); var encllength = document.getElementById("item_encllength"); var form = document.getElementById("rss2_feed"); encllength.addEventListener("mousedown", update, false); form.addEventListener("submit", update, false); function update() { encllength.value = ((min.value * 60) + sec.value) * 1000 }
  15. If you want to prevent the menu from hiding on mobile devices, remove the "w3-hide-small" class from the menu.
  16. The + operator in SQL only does mathematical additions. To concatenate words, use the CONCAT () function.
  17. It looks to me like hiding the menu was not a mistake but a deliberate part of the design. The menu wouldn't fit as it is on a mobile screen. I can't check the code right now, I might get to it later. You should use your browser's inspector to see which CSS rule is hiding the menu.
  18. If people weren't replying before, making a duplicate thread is not going to compel them to do it. I'm closing this thread, discussion about the issue can continue in the original thread: http://w3schools.invisionzone.com/index.php?/topic/56811-how-to-put-a-text-under-a-text/ The reason people are not answering is that there is not enough information to work with to solve the problem.
  19. The save() and restore() methods are useful for that. save() remembers the current state, restore brings back the state of the last save() call. ctx.save(); // Remember the current state ctx.translate(100,100); ctx.fillRect(0,0,100,100); ctx.restore(); // Return to the previous state ctx.fillRect(100,100,50,50);
  20. The W3Schools staff don't read the forums. If you found a mistake on one of the pages, scroll down to the bottom of that page and click the "Report error" link.
  21. PHP doesn't work that way that I can remember, that's a Java thing. You can do an experiment to confirm.
  22. None of the syntax would have to change, he's already doing everything correctly. I assume that when PHP sees an assignment to an undeclared property it creates the property, from that moment onward everything's the same as if the property had been declared. The only thing I notice that won't work is that he's calling a method get_feed_items() which doesn't exist.
  23. I'm not sure what your question is. You seem to know how to use iframes, so you can just create a page with 10 iframes.
  24. Set the line-height to 200px, that will keep the text in the middle. This won't work if you need more than one line of text.
×
×
  • Create New...