Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 09/20/2021 in all areas

  1. The DISTINCT modifier doesn't apply to fields, it applies to the query as a whole. You can think of "SELECT DISTINCT" as a single keyword which searches for unique rows. The AND operator will return a row only if both conditions are true. The OR operator will return a row if either one of the conditions is true. The query is looking for rows where Country is not Germany AND also Country is not USA. If you used OR instead then it would return all of the rows. The expression (NOT Country='Germany') means "all possible values except Germany" The expression (NOT Country='USA') means "all possible values except USA" The union [OR] of those two sets is all possible values, because any value that one of the sets lacks exists in the other set.
    1 point
  2. If you intend to use the border in order to give the underline a different color then you will have to use only border properties and remove the text decoration because the underline given by the text-decoration property is always the same as the text . a { text-decoration: none; border-bottom: 1px solid; } a:visited { border-color: #3b633b; } a:hover { border-bottom: none; }
    1 point
  3. As I said, this code has to run after the other code has generated the HTML and I don't have enough information about your page to determine when that happens. I need to see the whole page to actually identify how the code is being loaded. At the moment, all I can do is make guesses, so my suggestions are not guaranteed to work, of if they do I can't be certain they'll work 100% of the time because of variable loading times. My first guess is to run the code after the onload event. This probably won't work because, if the other code is using AJAX to load the content, it may take longer than the full page load time to appear: window.addEventListener("load", updateButton); function updateButton() { var button = document.body.lastElementChild.querySelector("button"); button.style.background = "#FFF !important"; button.style.color = "#000 !important"; } The catch-all fallback is to just wait a while using setTimeout(). The hard part is deciding how long to wait. If you wait too little, the other code won't have loaded yet; if you wait for too long the buttons will appear visibly unstyled for a period before changing. // Wait 800 milliseconds and then try to style the button setTimeout(updateButton, 800); function updateButton() { var button = document.body.lastElementChild.querySelector("button"); button.style.background = "#FFF !important"; button.style.color = "#000 !important"; } By the way, you don't need the "!important" rules because you're deleting the rules that are already in place.
    1 point
  4. Wow, those guys really do not want their styles changed. I would have suggested overriding it with CSS, but they have !important rules inside a style attribute, there really is no way around that without Javascript. Once you have a reference to the button, you just have to change the style property of the button which is easy. In order to get a reference to the button you have to write some code that is guaranteed to run after the script that loads this HTML, which I don't have enough information about your page to do that. The code which would get a reference to the button (provided you run it at the right moment) is this: var button = document.body.lastElementChild.querySelector("button"); // Once you have the button, you can change any of its properties button.style.backgroundColor = "#FFF"; button.style.color = "#000";
    1 point
  5. For the most basic functionality, all that's missing is to get the values of the shipping fields like this: function billingFunction() { if (document.getElementById ('same'). checked) { document.getElementById ('billName'). innerHTML = document.getElementById('shippingName').value; document.getElementById ('billZip'). innerHTML = document.getElementById('shippingZip').value; } } However, I noticed that this doesn't account for the person changing the shipping or billing address fields after the checkbox has been clicked. A complete implementation needs to prevent the user from editing the billing fields and update the billing fields whenever the user changes the shipping fields. It would take too much time to try to teach the whole process of doing this in a forum post, so I'll write the resulting code for it. <p> Shipping Information </p> <label for="shippingName"> Name </label> <input type="text" name="shipName" id="shippingName" required> <br/> <label for="shippingZip"> Zip code: </label> <input type="text" name="shipZip" id = "shippingZip" pattern=" [0-9]{5}" required> </br> <input type="checkbox" id="same"/> <label for="same"> Is the billing information the same? </label> <br/> <br/> <p> Shipping Information </p> <label for="billingName"> Name: </label> <input type="text" name="billName" id="billingName" required> <br/> <label for= "billingZip"> Zip code: </label> <input type="text" name="billZip" id="billingZip" pattern="[0-9]{5} " required> <br/> <input type="submit" value="verify"/> <script> (function(){ var checkbox = document.getElementById("same"); var shippingName = document.getElementById("shippingName"); var shippingZip = document.getElementById("shippingZip"); var billingName = document.getElementById("billingName"); var billingZip = document.getElementById("billingZip"); checkbox.addEventListener("change", linkShippingAndBilling); function linkShippingAndBilling() { if(checkbox.checked) { // Listen for changes in the shipping fields shippingName.addEventListener("input", updateBillingName); shippingZip.addEventListener("input", updateBillingZip); // Update the billing fields billingName.value = shippingName.value; billingZip.value = shippingZip.value; // Make billing fields read-only billingName.readOnly = true; billingZip.readOnly = true; } else { // Stop listening for changes in shipping fields shippingName.removeEventListener("input", updateBillingName); shippingZip.removeEventListener("input", updateBillingZip); // Clear billing fields billingName.value = ""; billingZip.value = ""; // Remove read-only from billing fields billingName.readOnly = false; billingZip.readOnly = false; } } function updateBillingName() { billingName.value = shippingName.value; } function updateBillingZip() { billingZip.value = shippingZip.value; } })(); </script>
    1 point
  6. Have you started writing the Javascript yet? Show me what you've tried and I can help fix any mistakes. If you haven't started writing the Javascript, here are a few tutorial pages explaining some of the steps you need to take: Finding the HTML elements Reading and writing to text fields Adding an event listener (to detect the checkbox changing)
    1 point
  7. I think the W3Schools tutorials should be good enough as long as you dedicate your time to it. Once you are done with the HTML tutorial, you should go through the CSS and Javascript tutorials. They don't have video tutorials for CSS and Javascript, but the written tutorials are free. Once you have read all of those tutorials carefully, you can look at the code of the W3Schools How To examples and try to understand how they work for practice. The best way to learn is working with code and seeing how your changes affect it.
    1 point
  8. It looks like the flash player elements on those pages were for a slideshow and an mp3 player. These pages have some example code for slideshows: https://www.w3schools.com/howto/howto_js_slideshow.asp https://www.w3schools.com/howto/howto_js_slideshow_gallery.asp For playing sounds and music, you can use the HTML 5 <audio> element as shown in this tutorial: https://www.w3schools.com/html/html5_audio.asp To fully understand and work with the code you will need to dedicate some time to learning HTML, CSS and Javascript.
    1 point
  9. Let's set a few things up first. Firstly, in HTML create the image tag with an id and some alt text: <img id="image" src="image.png" alt="image-text"> Next, in JavaScript let's assign the image tag to a variable. Doing so will make it's alt property accessible for later use in the div tag: // assign the img tag by id to the "img" variable let img = document.getElementById("image"); Now let's create an empty div in HTML, with an id of "alt-text". You can do this entirely in JS, but let's use HTML for this example. Add it just below your img tag from the first step: <div id="alt-text"></div> Next, in JavaScript let's create a variable to reference the empty div and a function to set the text and background colour of the div: imgFunc = () => { // assign the empty div to a variable let altDiv = document.getElemenetById("alt-text"); // set the text of the div to the alt property from the img variable created earlier altDiv.innerHtml = img.alt; // set the background colour of the div altDiv.style.backgroundColor = "blue"; } Now, there are better ways to set the text, but innerHtml is a quick way to demonstrate. Explore the options available to you on the W3Schools website. I've gone with blue here as the background colour, but you can choose whatever colour you want. Finally, let's add a mouseover event to the img tag from the first step, and use it to call our function: <img id="image" src="image.png" alt="image-text" onmouseover="imgFunc()"> And that's it.
    1 point
  10. CSS background properties do not apply to HTML images, only to files specified by the CSS background-image property. The <source> element doesn't have a background-image attribute, you need to use the src attribute instead. I don't think CSS styles work on <source> elements because they merely are used to identify a resource on a server, it's the parent <picture> element that needs the CSS styles. There is no equivalent of the CSS background-size: cover for HTML elements. I don't see a reason to use HTML for this problem, it would be best to just use the CSS background image. If you want different images based on screen size then you can use media queries. For widths, you can either choose to expand to fit the container or set a fixed value like 2000px; it doesn't make sense to have both. A full CSS example would look like this: .bgimg { background-position: center; background-size: cover; background-repeat: no-repeat; background-image: url("img/small.jpg"); min-height: 75%; } @media screen and (min-width: 601px) { .bgimg { background-image: url("img/medium.jpg"); } } @media screen and (min-width: 1501px) { .bgimg { background-image: url("img/large.jpg"); } } If you want to set the size of the background image for each screen size then you can put a background-size declaration in each media query. It does not make sense to use background-size: cover in this scenario because it will be overridden. Here's an example with a fixed image size per screen size. .bgimg { background-position: center; background-size: 600px auto; background-repeat: no-repeat; background-image: url("img/small.jpg"); min-height: 75%; } @media screen and (min-width: 601px) { .bgimg { background-image: url("img/medium.jpg"); background-size: 1500px auto; } } @media screen and (min-width: 1501px) { .bgimg { background-image: url("img/large.jpg"); background-size: 2000px auto; } }
    1 point
  11. When creating a cookie in Javascript, setting the domain component to your top level domain will make the cookie accessible to all subdomains. Here is an example: document.cookie = "username=John Doe; domain=example.com"; The above cookie will work on example.com and also subdomain.example.com.
    1 point
  12. If the pages are on the same domain then they should already have access to the same cookies. Trying to preserve a session through query strings alone is very difficult and you can't guarantee that the session key won't be lost somewhere during the user's activity. There is also a security concern where, if somebody copies the URL and sends it to another person then that other person will have access to the same session. If you just want to direct the user to another page with a query string attached, you can use the location object. location.href = "somepage?var=value"; If you have a cookie's value stored in a variable (see how to get a cookie's value here) and want to send it in a query string then you can concatenate it to the string, using encodeURIComponent() to prevent malformed URLs. var cookieValue = "Pretend that this string came from a cookie"; location.href = "somepare?var=" + encodeURIComponent(cookieValue); If you actually want every link on your page to have a special query string attached, it will involve a lot of string manipulation, which is tedious. You will need Javascript to loop through every <a> element on the page (using document.getElementsByTagName("a")), check that the href property belongs to the same domain, then append your value to the query string to the URL and then assign the modified URL back to the link's href property. Useful string manipulation functions are shown here: https://www.w3schools.com/js/js_string_methods.asp
    1 point
×
×
  • Create New...