Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by justsomeguy

  1. No, that code probably isn't going to work like you expect. What exactly are you trying to do there? If you're trying to get the value of an input element, you need to use something like document.getElementById to get the element.
  2. If you want to check if something is greater than or equal, instead of this: if (A = or > B) you do this: if (A >= B) Here's a list of operators: https://www.w3schools.com/jsref/jsref_operators.asp
  3. Right, nothing works for all browsers, which is why you're trying multiple ways. I would add the example on that page. You're saying it's not working now, so why not try another way, right? I would start minimal, right now you have a bunch of stuff that apparently doesn't work. I would start over with just the code on the page I linked to, and get that working. Then, try it with other browsers. If something like IE doesn't support that, then add your code that checks if it's IE and do the other method, and test each time to make sure everything still works. That's going to be easier
  4. I'm not sure about doing the whole thing with the range, you should just need to select and copy: https://www.w3schools.com/howto/howto_js_copy_clipboard.asp I don't know if document.execCommand is case-sensitive or not, but they show "copy" there. You also might want to do an else to show an alert if none of the other two if statements match, for testing. Also, you set elm to whatever the return value of the select method is, not the element itself.
  5. For that example, the easiest way would be to use different class names for your other slideshow. So use mySlides2 and dots2, for example, and make a copy of that Javascript code with a different function to run the second slideshow with the other class names.
  6. You can also just combine those so that whenever you click on a text area it selects all of the text and then copies it.
  7. Yeah, but that function isn't going to get an ID passed to it for the clipboard, I don't know where that is supposed to come from. But the event object e does get automatically passed to an event handler and you can pass that through to another function. Is x supposed to be the ID of the textarea that was clicked on that you want to select? Because you don't need to pass that, the element which triggered the event will be part of the event object. Like in the select function, where you use e.currentTarget.
  8. Just give the cookies names with the usual set of characters. When the page loads then check which cookies are available and fill in your own array structure.
  9. Create a third function which decides which other function to call. You can pass the event object and any other parameters to the next function also.
  10. If you want to eliminate spam you need to personally validate what's there, which is probably more work than you want to do. If you're already using Matomo or something else for search, then I would look at the capabilities of that. If you're not using anything to help search, then yeah you're on your own with writing the code you want to use, otherwise I'd look at capabilities of what you're using to help search.
  11. Not the way I think you're using it, as in "displaying search terms." It is a simple general data visualization tool to identify the most common terms in some set. If you are applying that to user-supplied input, that's what I'm wondering and that's what I'm asking. In general, you just need to figure out what business rules you want to use for that. How specifically do you want validation to work, what do you want to validate? Do you want to use a whitelist, a blacklist, or some other method?
  12. Square brackets may or may not be supported in various browsers as a cookie name. You can always see what the browser sends the server using print_r($_COOKIE). I would recommend using only alpha-numeric characters plus underscores and hyphens for cookie names.
  13. As "word cloud" is not a well-defined term, are you saying that you're displaying on your site the search terms that people search for? If that's the case, if you're displaying user input on your site, and want to avoid spam, then probably the only way to reliably do that is to only consider search terms that you have validated. So you would need to build a way for you to periodically review and validate the search terms that you want to be included. Removing unwanted characters is as easy as doing a string replace to find and replace whatever you want to exclude. You can use a whiteli
  14. Yes, cookies are just regular key-value pairs. Each cookie has a name, and a value. Like a variable. To set a cookie, you use the setcookie function. To read cookies that were sent in the current request, they'll be in the $_COOKIE array similar to $_GET or $_POST. More or less. You could store a serialized array in a cookie (check the maximum value for cookies in various browsers to decide if that's a good idea), but you're storing those cookies on the user's computer. They can easily change anything about it and send it back, so you probably don't want to unse
  15. You've got 2 functions with the same name, that's an issue. If you want to remove or edit something then start with a button or other link that you create when you create that item and put a click handler on it, start there and make sure you can run the click handler. The handler should be able to figure out which element was clicked on and get the corresponding li to remove or edit.
  16. You almost had it with your changed code, it's just that e[comp1] && e[comp2] doesn't do what you expect or intended.
  17. Add output statements similar to what I have, you should see why it's not comparing things the way you expect.
  18. Are you referring to code that was edited into your first post?
  19. Here's a version if you're not into the whole brevity thing: function getUnique(inputArr, comp) { const unique = inputArr.map(function (e) { // return an array of only one property from the original array of objects (if defined) console.log(e[comp]); return e[comp]; }).map(function (e, i, final) { console.log("final", final); console.log("e", e); console.log("i", i); // return an array of either false values or indexes // this will result in an array where each value is listed only once, in the first position it appears, // and any ot
  20. You need to pass null for that column if you want it to auto-increment. Or, better yet, list the columns you are inserting and leave out the auto-increment column completely.
  21. I don't think you'll get a lot of discussion about downloading a zip file for an application that is supposed to be used with a stack that is now deprecated.
  22. If it's on port 80, that's correct, because port 80 is what the browser uses for HTTP. You need to specify the port in all of your URLs: http://localhost:81
  23. You're not saving the return value of toFixed.
  24. It looks like it's running on port 81, can you not access it on that port?
  25. It gets the next sibling of the element. I don't know what element that is because I haven't seen the elements, just the Javascript. Siblings are elements with the same parent.
  • Create New...