Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by justsomeguy

  1. If you're loading the Javascript in the head instead of the body then you need to use a window load handler to run the code after the page finishes loading.
  2. I think the root issue is that an accordion is a box-shaped bellows-driven free-reed aerophone type keyboard instrument. It is not in the percussion family.
  3. Yeah it's going nuts trying to figure out the CDATA crap, look at all of the stuff it added. Don't just paste all of that back in to the CMS, you need to remove all of the CDATA stuff and paste your original code back in.
  4. Keep an eye on your browser's developer tools on the Console tab for Javascript error messages, but you'll get an error that's due to the capital ID when you try to get the values: var val1 = document.getElementByID(a).value; Javascript is case-sensitive, this is the correct way: document.getElementById(a)
  5. I meant error messages from your browser, not the CMS. Open your browser's developer tools and check on the Console tab for Javascript error messages.
  6. You messed up the quotes in the ID in the th element, the browser doesn't know where that element ends and it's printing the Javascript instead of running it.
  7. Bad programming. That's OK, that's the point of making the first line a useless comment. The code you're showing should work fine. Are you getting any error messages?
  8. And you want to validate the email, when, when you display existing posts? Wouldn't it make more sense to do that when someone creates a post so that you don't allow them to create it in the first place? I'm trying to figure out why you're doing anything at all on a page which displays data from the database instead of the pages that add the data to the database. This is still aside from the fact that thee code you showed is not even getting the forum posts at all, it's only getting the email list and that's all.
  9. The CDATA sections aren't really a problem, they're not necessary at all but they're inside comments and aren't going to break anything. The extra elements mean that this line doesn't work: var panel = this.nextElementSibling; That's why you're getting the error message about panel being null. If you can't do anything about the paragraphs then you can change that line to get this.parentNode.nextElementSibling instead.
  10. What do you mean check and store the email that was removed from posting? All you're doing is trying to list the records that are in a table. Do you mean you want to skip records that have an email address that you blocked or something, so that existing posts in your database that were made with that email no longer appear?
  11. It looks like your web server doesn't support PHP or isn't executing the code for some reason, maybe it's not a .php file.
  12. You can use document.getElementById to get the values in the inputs and do your calculation, but if you want to put the result in another element then give the target element an ID also. For the Javascript code, put your calculation in a function, pass anything that might differ (like the IDs to get and set), and pick an event when you want to run the function. You showed using the change event earlier, that would work.
  13. If the "accordion" button is inside a <p> element, and it's the only thing in the <p> element, then like dsonesuk said it's not going to work because the Javascript looks for the accordion's next sibling. If it's inside an element by itself then it has no sibling. Review the markup on the w3schools site to see how it's set up, the div should be right next to the button.
  14. Yeah, the CMS is breaking it because it decided to comment out your first line of code. That's why I suggested adding your own comment as the first line. If it's going to comment out the first line of your code then make the first line not matter.
  15. If you want the calculated values to each go in a cell like in the rest of the table, the first thing to do is to make the cells that will hold the calculated values. Your rows that you want to calculate only have one cell. Also, th cells are supposed to go in the head of a table, the body would normally contain td cells. Add the cells that will be the placeholders for the calculations and then you can write your code to do the calculations. It's also better to use the code box in the forum when you're posting code.
  16. It would be better if you used a code block on the forum here to post your code. If your CMS is adding code to effectively comment out the first line of your Javascript, maybe just add your own comment as the first line.
  17. You're not selecting and displaying records from the forum table, you're using the email table. Look at the code.
  18. Yeah, a lot of big projects have bad ideas. No reason to copy them. Are you saying that you have a table called "email", and in the email table you have columns for first_name, last_name, post_date, email, and message? If that's true, then why did you decide to name that table "email?"
  19. You guys can go ahead with however you want to set it up, but it is not efficient to have a table hold everything and say what is blocked. It is much more efficient to have a table only contain what is blocked. If you really want to list everything and have a column saying whether it's blocked I'm not going to stop you, it's just a bad design.
  20. If you put the ID in the right place on the element then that would work to update the innerHTML for that one element when the page loads. If all of the calculations are the same then have a function that takes whatever values change. You only need to write it once. function calculate_pressure(a, b, dest) { var c = 0.052; document.getElementById(dest).innerHTML = document.getElementByID(a).value * document.getElementByID(b).value * c; } When you call that function you can pass the parameters to tell it what to do, e.g.: <button onclick="calculate_pressure('Interval-1-EndTVD', 'Interval-1-EndMW', 'Interval-1-Hydrostatic');">Update</button>
  21. Each cookie is just a generic data store, it just has a name and a value. The value can be anything the site wants to set (within size limitations) and doesn't need to be human-readable, maybe it's just an ID string to match up with a database somewhere, maybe it's encrypted data that the site decrypts. There are other properties that cookies can have but that's the basic idea, just a name and a value.
  22. No.... no, the words "make" and "separate" do not appear in your post: Maybe you thought you did, but you didn't say to make a separate table, so it seemed like a good idea to point that out. In fact, it sounds like you're suggesting adding all IPs to a table: That's not a good idea. Don't do that. Don't have a "block column," do not use a column to state if an IP is blocked or not. Every IP in the table is blocked, that's the specific purpose of the table. You're not describing the same thing I am, you keep talking about a column to store whether it is blocked. That's not a good idea. There's no reason to have a separate table to list all IPs that have accessed the site, you can get that information from the various other tables where the IP is stored along with the post/account/etc. The table of blocked IPs should only list IPs that are blocked. There is no "block column" anywhere.
  23. No, you said "a table to hold singular unique IP addresses and a blocked column." That's not efficient. Store the IPs along with whatever else makes sense (posts, accounts, etc), but have a separate table for blocked IPs and only list the blocked IPs, not every IP with a column indicating whether or not it's blocked. When you're checking if an IP is blocked you only need to look through the blocked IPs, not every IP. If the point is a blacklist it doesn't make sense to also list everything that is not blacklisted. Just list the blacklist.
  24. Use MAX if you want the largest value or MIN for the smallest. You need to group by every column that is not part of the aggregate function.
  25. You need to do the calculation like this, you don't just write the ID as a string and assume it's going to get the value of an input element with that ID: var z = document.getElementById(a).value * document.getElementById(b).value * c; You also need an event when that code runs. Events are things like clicking on a button, or pressing a key, or changing the value of an input. Look up event handlers and put your calculation code in an event handler for whatever event you want to use. Right now your code only runs once, when the page loads, so it's not going to respond to any events like filling in the various inputs.
  • Create New...