Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing html table to different page

Status
Not open for further replies.

vinzen

Programmer
Jan 19, 2010
2
US
This post is very similar to the "passing javascript variable to a different page" post of yesterday, except instead of a variable it is an html table.

I have one page that builds an html table, and I want a different page to run thru the table and process the rows.

It sounds like this is something that can't be done (according to the responses of the previous post) -- is that right?. Do I need to do all of my processing on the same page? If now, how can I reference the table without passing tons of variables? How do most developers do something like this?

Sorry for my ignorance -- extreme newbie here..

vinzen
 
Hi

vinzen said:
I have one page that builds an html table
What do you mean builds ?
[ul]
[li]sets the attributes of [tt]table[/tt], [tt]tr[/tt], [tt]th[/tt], [tt]td[/tt] tags[/li]
[li]sets the content of the table cells[/li]
[li]both[/li]
[/ul]
Anyway, all of those can be handles just like any other values and be passed as in the mentioned thread. ( By the way, please use [TGML] references like [ignore]thread216-1587025[/ignore] to generate references like thread216-1587025 . ) Of course, some things can be automated using arrays. Or just pass the HTML code of the [tt]table[/tt] and its children as one huge string.

But personally I would try to do all the job in the same page.

Feherke.
 
Feherke,
Thanks for the response. By "builds" I did mean both -- both the attributes and the content of the table gets created. I will probably take your advice and do it all on the same page -- I just thought it might be easier to maintain if the logic was separated a little bit.
vinzen
 
You could pass the contents of innerHTML of whatever object holds the table into a variable and pass that to the other page.

This should yield everything that was done to the table. You'll get a string with the table architecture, that can then be placed into another object, or manipulated as a string if you need to.

Code:
<script>
function Get_Table_String(tblParent){
var tblPrnt=Document.getElementById(tblParent);
var tblString=tblPrnt.innerHTML;
return tblString;
}

</script>
<div id="mydiv">
<table><tr><td>First cell of first row</td><td>Second Cell</td></tr>...</table>
</div>



This will put the table code into a variable that you can then manipulate further as you need.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top