View Full Version : How to put a table cell content in a variable?

12-14-2010, 10:08 PM
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.

12-14-2010, 10:33 PM
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.

12-14-2010, 10:38 PM
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.

12-14-2010, 10:44 PM
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.