Jump to content

denno020

Members
  • Content Count

    761
  • Joined

  • Last visited

  • Days Won

    3

denno020 last won the day on May 3 2019

denno020 had the most liked content!

Community Reputation

22 Good

About denno020

  • Rank
    Prolific Member
  • Birthday 02/22/1987

Profile Information

  • Gender
    Male
  • Location
    Australia

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. The issue you're running in to is one of timing. The fact that you can see the toastr at all is very surprising, and likely because there aren't any other actions being performed on click.. As soon as there are some actions being performed within the click handler, then the toastr likely won't ever be seen! Unless of course, we fix it! Essentially we need to tell the browser to stop processing the click event so the page refresh doesn't occur Something like this will get you going: <script type="text/javascript"> $(document).ready(function () { $('#add').click(function (e) { e.preventDefault(); // Stop the browser from redirecting to click target (i.e. the href) // Perform actions // ... // ... toastr.success("Folder 2 has been clicked!", "Folder 2", ); window.setTimeout(function () { toastr.clear(); }, 3000); }); }); </script>
  2. I completely agreed with @requinix, this is a situation where jQuery excels, and will save you a lot of time and headache. It's definitely possible to do this with vanilla JS, but it's a lot more code. One suggestion I will make is to use a `<template>` element, which can contain the HTML that you will clone. This way you don't have to clone an existing HTML DOM node, which will contain user changes and would require you to go through each field and clear the values of the inputs/textarea before injecting it into the page as a new node. Check out the MDN docs for `template`, they have great example code (which is actually in vanilla JS, so you can see how much is required!) Another thing I would suggest is to avoid using a `div` as a button. The New Line "button" has the `btn` class on it, but it's a div. This will be inaccessible to site visitors, so best to use a `button` element, with those same classes. P.s. Please excuse the use of back ticks, it appears the forum doesn't support markdown
  3. The offending line that is only allowing you to search the first column is this one: td = tr[i].getElementsByTagName("td")[0]; The `[0]` portion of that statement means to literally get the first column only. An easy fix is to add a nested loop, that does essentially the same as the for loop for the `tr` element, but do it for `td`, provided `td` is assigned: td = tr[i].getElementsByTagName("td"); Simply move the if block inside that inner loop, and it should work (some variable names inside that second for loop will need to be updated) As for making this work with any table, I feel like the call to the function needs to pass a string. Without the quotes around customerTable, the code is going to assume that's a variable name, so maybe try updating to: onkeyup='searchTable("customerTableSearch", "customerTable")' These are all suggestions that require a minimal amount of refactoring of the current code, this doesn't mean I endorse that way it's written , there's lots of improvements that could be made for this to be much more maintainable in the future, but we'll leave that for another discussion
  4. I have never used Audio previously, but looking at the docs, audio.load() will reload the file, which means you should be able to omit it here. Also, the event to listen for is "loadeddata", rather than "load".. See how those updates go
  5. You're going to want to make use of setTimeout. The syntax is as follows: setTimeout(function() { // Execute this code after the timeout of 1000ms }, 1000); Keep in mind that this function is asynchronous, which means $(document).ready(function(){ setTimeout(function() { intro('#hello', '#world'); }, 1000); setTimeout(function() { intro('#hi', '#all'); }, 1000); setTimeout(function() { intro('#hola', '#amigos'); }, 1000); }); Will execute all into functions after 1 second. This could be a solution: $(document).ready(function(){ setTimeout(function() { intro('#hello', '#world'); }, 1000); setTimeout(function() { intro('#hi', '#all'); }, 2000); setTimeout(function() { intro('#hola', '#amigos'); }, 3000); }); However that will quickly fail if the execution of the next function has to be 1 second after the previous function has finished (assuming there might be some delays/user input/processing inside the intro function) Hopefully that's enough information to get you on the right track to figuring it out
  6. Which colour are you trying to change? The `color`, which is the text colour, or the `background-color`? I can see the background colour of the button is `background-color: rgb(48, 133, 214)`, which is added as an inline style, using the `style` attribute. To overcome that, you're going to have to get more specific when writing your own style, and the only way to do that is to use `!important`: .swal2-confirm { background-color: purple !important; }
  7. First, to make your code easier to read, I suggest you write it like this: <script type="application/javascript"> (function($) { $(document).ready(function() { $(" .et_bloom_submit_subscription").click(function() { var $subscibeButton = $(this); // same as $('.et_bloom_submit_subscription') var $form = $subscibeButton.closest('.et_bloom_form_container'); var $firstName = $form.find('.et_bloom_subscribe_name input'); if ($firstName.attr('value') == '') { $firstName.addClass('et_bloom_warn_field'); return false; } else { $firstName.removeClass('et_bloom_warn_field'); } }); }); })(jQuery) </script> It caches jQuery objects so that you're not having to constantly parse the DOM, which will give a slight performance boost, but it will also make it much more obvious as to where the last name check should go <script type="application/javascript"> (function($) { $(document).ready(function() { $(" .et_bloom_submit_subscription").click(function() { var $subscibeButton = $(this); // same as $('.et_bloom_submit_subscription') var $form = $subscibeButton.closest('.et_bloom_form_container'); var $firstName = $form.find('.et_bloom_subscribe_name input'); var $lastName = $form.find('.et_bloom_subscribe_last input'); if ($firstName.attr('value') == '' || $lastName.attr('value') == '') { // Use .toggleClass so the second parameter will add/remove the warning class if only one of the fields is empty $firstName.toggleClass('et_bloom_warn_field', $firstName.attr('value') == ''); $lastName.toggleClass('et_bloom_warn_field', $lastName.attr('value') == ''); return false; } else { $firstName.removeClass('et_bloom_warn_field'); $lastName.removeClass('et_bloom_warn_field'); } }); }); })(jQuery) </script> There are a few other optimizations/updates that I would make to this code, if it were mine, but for the sake of simply answering the question, I won't change too much :). Hope that helps! Denno
  8. A quick and slightly dirty way you could achieve this is by wrapping your checkbox groups in a single element (div for example) and wrapping your tables in a single element also (but not the same one). So it would be something like this: <div class="checkbox-groups"> <!-- All of your checkbox groups --> </div> <div class="tables"> <!-- All of your tables --> </div> Then, you can use jQuery's index() function to get the index of the group that contains the checkbox that is activated, and then find the corresponding nth-child() in your tables div. Something like the following pseudo code $('input[type="checkbox"]').on('click', function(e) { var $checkbox = $(e.target); var index = $checkbox.index(); // Find corresponding <table> in the .tables element var $table = $('.tables').find('table:nth-child('+index+')'); // Loop through table cells to determine which should be highlighted }) I have written that using ES5, as your Fiddle is also written using ES5, but it could be cleaned up a but with arrow functions and template literals from ES6, should you happen to have access to a build tool or don't care about support for IE. If you can have a crack at implementing something like that, and post back with results, I'll be happy to help further with your solution
  9. The only way to get a value from JS to your PHP is to send a request from the JS to your server. This could either be through a form submission or an AJAX request PHP is run on the server, whereas JS is run on the client, essentially 2 completely different places that each have no idea about the other.
  10. There are issues with your code, no doubt, but what our friend above didn't mention is the reason you're getting the error is because you've got a semi colon at the end of line 8, even though you then try and concatenate another function call. Remove that semi colon and your code shouldn't complain. Whether it works as you expect it to is what you'll need to test next Denno
  11. Hi Stephie22, A Google for "Javascript carousel" turned up this, which looks quite nice: http://kenwheeler.github.io/slick/ Otherwise just run the same search and see what you can come up with, there will be a tonne of existing plugins/libraries etc
  12. Update: I have got back in touch with the hosting provider and am speaking to a different person now, and they're telling me that imagewebp isn't enabled and that I can't get it enabled because it's not supported on shared hosting. So seems there is nothing I can do about it. Thanks anyway
  13. Thanks for the response. How would I check the version of GD that is installed? I did suspect this could be the problem, but I didn't realise they were installed separately, so I (apparently wrongly) assumed that it was inside PHP itself. Also, as I mentioned, when running phpinfo() on the production server, it lists webp in the following two sections: HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 $_SERVER['HTTP_ACCEPT'] text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Is this not related to GD?
  14. I'm having a weird issue with the aforementioned function inside my site. Here is an excerpt of code: if ($extension == 'jpg' || $extension == 'jpeg') { $isSaved = imagejpeg($image, $filename, $imageQuality); } elseif ($extension == 'gif') { $isSaved = imagegif($image, $filename); } elseif ($extension == 'png') { if ($imageQuality >= 100) { $imageQuality = 0; } elseif ($imageQuality <= 0) { $imageQuality = 10; } else { $imageQuality = round((100 - $imageQuality) / 10); } $isSaved = imagepng($image, $filename, intval($imageQuality)); } elseif ($extension == 'webp') { $isSaved = imagewebp($image, $filename, $imageQuality); } else { throw new Exception(sprintf('Image format "%s" not supported.', $extension), self::ERROR_NOT_SUPPORTED_FORMAT); } The issue is with the webp section, when this code runs (having passed a webp image to it), I get this exception Fatal error: Call to undefined function Image\Core\imagewebp() in ...... To me it looks like PHP isn't picking up the function as a native PHP function. I am able to use this code perfectly fine on my development machine (windows machine using WAMP with PHP7), but the issue seems to arise when this code is run on my production server. I have been in touch with my hosting provider just now, and they weren't able to enlighten me at all, actually telling me that I need to check the scripts or with a developer that can fix it. The production server is also running PHP7, and webp appears to be enabled (checked using phpinfo()) Does anyone know how I could continue to debug this issue? Thanks Denno
  15. In the interest of completeness, something I didn't add to the jsFiddle is to break the loop(s) once you've found the data you want. Don't need to waste time looping through the rest of the data if you already have your translation value
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.