Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Posts posted by justsomeguy

  1. 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.

  2. 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)

  3. I'm really unsure why it's happening.

    Bad programming.

    The CDATA just writes over what you wanted me to add.

    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?

  4. 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.

  5. 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.

  6. 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?

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

  12. Bad joomla for using such a method bad bad jommla.

    Yeah, a lot of big projects have bad ideas.  No reason to copy them.

    If you see, I'm trying to picture what needs to go where,

    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?"

  13. 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.

  14. 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>

  15. 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.

    • Like 1
  16. Quote

    Then said

    Make a separate table to store blocked ip/email

    No.... no, the words "make" and "separate" do not appear in your post:

    Quote

    If the table stores multiple rows with identical  emails or ip addresses its going to almost impossible to block effectively. You would need to have a table to hold singular unique emails OR ip addresses and an blocked column. This column will be type boolean taking true and false value with default false. As administrator you alone would have access to a form list of email or ip addresses to block.

    Once a posting is made the email/ip IF new is added to blocking table at the same time it will check if current email/ip is listed as blocked, if yes ignore else show.

    Normally this block column is stored with users registration details such as name, email address, username, password, but i have a feeling this is not the case with the forum code you're using.

    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:

    Quote

    Once a posting is made the email/ip IF new is added to blocking table at the same time it will check if current email/ip is listed as blocked, if yes ignore else show.

    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.

  17. What i said.

    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.

  18. 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...