Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2009
    Location
    Earth - sometimes sky :-)
    Posts
    121
    Thanks
    51
    Thanked 2 Times in 2 Posts

    How to put a table cell content in a variable?

    Ok,
    I have a table wit lots of cells in. All the cells have a content.
    I wish to put some cell content from the table in a variable with a submit button which is at the end of rows.

    How can I read out a cell content and put it in a variable?

    Thank you.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Couple of ways... if you want a non-Javascript way then you'll need to use form input elements to store the bits of data in each cell. You can use the "readonly" attribute to keep the client from changing the data, but this is not fool-proof. When the form is submitted, the input elements will be sent in the post (or get) request for you to do whatever you want with.

    Another way is to use Javascript and DOM logic to extract the inner HTML from each cell and use it however you want.

  • Users who have thanked Fumigator for this post:

    joda (12-15-2010)

  • #3
    Regular Coder
    Join Date
    Apr 2009
    Location
    Earth - sometimes sky :-)
    Posts
    121
    Thanks
    51
    Thanked 2 Times in 2 Posts
    Thank you for your quick reply,
    what are you think witch one is the better way to use it?
    can you post me a short code maybe?

    Thank you.

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    If you're asking my opinion, I think HTML values should be output only, not stuff you use for input. It's too easy for a 12 year-old hacker wanna-be to change the values using Firebug or whatever and your application is compromised.

  • Users who have thanked Fumigator for this post:

    joda (12-15-2010)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •