Jump to content

requinix

Administrators
  • Posts

    15,265
  • Joined

  • Last visited

  • Days Won

    431

Everything posted by requinix

  1. When you look at most sorts of Javascript UI frameworks, you see a common design: they keep an internal "model" of what the UI looks like, do work on that, and then update the actual UI with the changes. While it seems like a lot of extra work, it makes the design a lot simpler as you can manage the internal model whatever way you want instead of being forced to observe how the page is laid out. Repeating that concept here would be helpful. 1. For each row that you need to update, keep an internal array of the values of the 12 input boxes. Each one starts with a value of zero (apparently). 2. When an input is changed, go into that row's array and update the month's value. That's one half of the functionality: keeping track of when the value changes. Every time this process completes you'll have an array of the current values for the row. 3. Take that array and update the row's total. 4. Update the MS% value too? I don't know what that's supposed to be. That's the other half. Each of those halves can be done more-or-less independently of each other. Here is where I would say "Before I continue, let's clean up that HTML some because it's painful to look at" but that would take quite a bit of effort. So I won't. 😓 But there are some changes that would be really, really helpful: * Change the markup for the input boxes so that you don't have to list out the months so often by adding a data-month attribute for the month number (counting from 0) * Get rid of their IDs because (a) they're more often a bad thing than a good thing and (b) you aren't using them anyways <input type="number" class="form-control" name="Jan[]" value="" style="width:100%" data-month="0" required/> Then add some Javascript. * Don't use keyup. There's a perfectly good event exactly for this sort of thing: input * Instead of adding event handlers for every single month input, make use of the fact that Javascript "bubbles up" events and add a single event handler to cover all of them $(function() { // for each row in the table, $("#example tbody tr").each(function() { // the 12 values for the months const values = Array(12).fill(0); // a running total that can be updated every time a value changes let total = 0; // arrow function means "this" is inherited from the current scope (ie. this == the table row) const updateTotal = () => { $("[name='Total[]']", this).val(total.toString()); }; // every time something with a data-month changes its value, $(this).on("input", "[data-month]", function() { // get the new value const newvalue = parseInt(this.value || "0", 10); // update the running total total += newvalue - values[this.dataset.month]; // put the new value into the array values[this.dataset.month] = newvalue; // update the total updateTotal(); }); }); }); Demo: https://jsfiddle.net/gyhu2k57/
  2. strtoupper is a PHP function. You are using Javascript. They are completely different things. newent.value is (presumably) a string. This page may be helpful to show you what you can do with it.
  3. $param is an array of values. It is not an array of values where one of them is the values combined together separated by spaces. If your query has 3 integers then your parameters array needs to have 3 integers.
  4. Your description doesn't say whether the signature is raw bytes in base 64-encoding or hexadecimal bytes, so you need to confirm which is those is desired. Otherwise, for the first line of code, my guess is you're not formatting the price with the correct "two decimal format". For the second, you seem to be using the merchant code value twice. Seems pretty clear to be just by looking at that line...
  5. Do you mean that you have it outputting "please work" at the moment you want to? The only things wrong with that second piece of code are (1) it doesn't call $citizen->selectCitizen() and (2) it's supposed to return a value ($res) that you can use to determine if it worked. You haven't really shown very much of your code, but it doesn't feel like standard MVC so far...
  6. If you want help understanding what an error message means and how to fix it then you really need to tell us what the error message is.
  7. What are you trying to execute? When what button is pressed? And what is your question that we can help you with?
  8. Well, first thing you're missing is valid HTML. Second is that you're using inline Javascript events from the '90s instead of modern event handlers. And third is that if you want to know about the form submitting then you should be having the form tell you when it's about to be submitted instead of the button when it's being "clicked". Fourth is that either of these is better than a confirm() dialog: 1. A checkbox in the form that says they want to do whatever it is the form does. Mark it required so the form won't submit without it being checked. Then you don't have to write any code at all. 2. A modal popup where you can customize everything and make it fit with the appearance of your site. The form's button instead triggers the modal, and the modal is what actually submits the form. Fifth is that cancelling an event requires either returning false from the inline code (which is also '90s code) or using an Event object that you can .preventDefault() on (modern).
  9. Aww, then it's adjusting for timezones. You can go the longer route too: const from = new Date($("#from").val()).toLocaleDateString(); Javascript isn't particularly good with dates, but it can do the basics if you're willing to learn more about it.
  10. Are #from and #to date <input>s? Use .valueAsDate to get Date objects, then call their .toLocaleDateString() methods to get the date in a locale-based format. It might not be exactly dd-mm-yyyy, but (a) it's probably still good and (b) you can customize it some if you want. const from = $("#from")[0].valueAsDate.toLocaleDateString(); const to = $("#to")[0].valueAsDate.toLocaleDateString();
  11. I have no idea what your hosting provider offers; if you/she uploaded the original files then you should be able to upload those files again, or if the hosting provider set up WP then they should be able to do that again. Finding out what was deleted would be really helpful - for you. Find out what files you're supposed to have, perhaps by setting up WP somewhere, and compare with the site to see what's missing. A bit more drawn out process will be to find and read whatever error messages are being created (because WP won't be just "down" without saying why) and use that as a clue. Perhaps some of those messages will be talking about trying to use files that don't exist...
  12. They're log files? Is it important to recover them? Since they are just, you know, logs... Files are files. Any sort of file recovery thing appropriate for that OS and/or filesystem would work, but those tend to need low-level disk access. Did you try asking the hosting provider if they can do anything?
  13. Are we talking "make an election" like CIA? I could help you with that... but then I'd have to shoot you.
  14. Is this another "someone else did some work for me earlier and I don't understand what they did so please do the work for me this time too" question? This $loggedin = $_SESSION['member_id'] ?? 0; plus this if ($loggedin) { both look very much like they qualify as "activated only when logged in as a user or admin". Have you tried applying that to "the link" (I don't know what link you're talking about) so that it only appears when the person is logged in?
  15. I'm confident that the less complicated one is the better solution. In terms of code, all you need is something that can tell what option the user selected, and something that can do what it needs to do to give the user the PDF they requested. Try writing the code yourself. If you have problems getting it to work then post what you have with a description of what you're trying to do and what problem(s) you're having with it.
  16. I hear a lot of "Barand did this" and "Barand did that". Do you actually know what he did? Because if you don't then that's a problem and you need to start learning... If you can read the code then the first thing you can do is find out/remember whether it's using mail() or a library. Which is it?
  17. One of those options is significantly less complicated than the other, and the outcome is the same.
  18. If the tutorial is telling you to do something you don't want to do then why are you using the tutorial? Tutorials are not documentation. Try reading the documentation.
  19. It doesn't matter to PHP. It does matter to HTML and your browser. Because you told it that the button should be connected to some form named "form". The real problem is that you were specifying a form attribute at all. 99% of the time you should not: just make sure the button is contained within the <form> and you're set. The only purpose of the form attribute is to associate the button (or other input element) with a <form> that's somewhere else on the page.
  20. Works for me, provided that I'm not using Firefox and that I think the desired behavior is to change the background color of the SVG to red. If you're trying to change the background color of the .inside-svg element then you've vastly over-thought this...
  21. It does automatically work. It just doesn't automatically work the specific way you want it to. kicken said to use session_set_cookie_params. Have you done that yet?
  22. Last time you asked about this, on our Discord as well as StackOverflow, and I believe you made a thread too, people pointed you to the API documentation. I'm reading through it right now and I don't see anything that says you cannot use custom prices for subscriptions. I do see really obvious ways to specify (1) that the checkout session is for a subscription, and (2) what price you want on each item. Have you even tried creating a (test) subscription with a custom price yet? Or are you just assuming that it's not possible?
  23. So you want to allow both (a) "TMP" plus 1-5 numbers, and (b) 1-5 numbers then "M"? 1. You need ^ and $ anchors, otherwise the regex will only check if the string contains something that matches it. 2. {5} means exactly 5, but you've been saying "up to". 3. What about zeroes? That's not in the regex now but I'd be surprised if you didn't want to allow them. 4. To allow both patterns, tell the regex that you want to allow both patterns using a | /^(\d{1,5}M|TMP\d{1,5})$/
  24. "Tag" is still fine. It's not like that term has died off or anything. And it applies to all... well, to all tags... not just certain ones. "META tag", "HTML tag", "NAV tag", whatever. "Element" is the other one in common usage. Means the same thing. Probably a bit more proper. Maybe the word you're looking for is "semantic"? Because the idea of those new tags/elements is that they have a semantic meaning: while DIV is just whatever, HEADER is specifically for "a header", and NAV is specifically for navigation, and such. Makes it easier for automated processes (like search engines) to analyze a page.
  25. Yes. it's possible to do this. But you need to change how you do events. Using inline on* events is old and makes solving your current problem a little harder. Your first step is to modify how your hover comments work to use modern Javascript practices with event listeners. Your HTML for the button will be as simple as <but1 type='button' id='1' class='btn btn-warning hover-comment' value='Savin'>1</button> That removes the onmouseover, onmouseout, and onclick handlers, and instead added a class name of "hover-comment". Your new Javascript code will add an event listener using that "hover-comment" (or whatever you want to call it) - how you do so depends and I can't tell just from what you've posted. Once you have the modified HTML and the comment hover functionality improved, it will be much easier to do the "store the comments in the buttons" that you want.
×
×
  • 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.