Link to home
Start Free TrialLog in
Avatar of Martin Cotterill
Martin CotterillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Pass Variables to another page

Hello everybody

What I want to do is to pass data contained in a script to another page and use the retrieved data to display content on the other page.

ie:
thisPage.html
<html>
<head>

<script>
function pants(pic, picname, picdesc, price) {
...
(What code do I put here to send the data to theOtherPage.html?)
...
}
</script>

</head>
...
...
</html>

-------------

theOtherPage.html
<html>
<head>
...
...
What do I put here to display the data retrieved from thisPage.html
...
...
</html>

I hope this makes sense.
Many thanks in advance.

Pantyboy
Avatar of StormyWaters
StormyWaters
Flag of United States of America image

There are several different ways to do it, but it depends on certain factors. Is thisPage.html a child or parent window of theOtherPage.html? Or does thisPage.html link to theOtherPage.html?
Avatar of Martin Cotterill

ASKER

Hi there

I'm sorry, I should have added that thisPage.html would have links attached to thumbnails and set out as <a href="javascript:void(0)" onclick="pants('woman-reading.jpg','Woman Reading','20 x 30 Acrylic on Canvas','£50')">View Larger Image</a>.

When the link is clicked, theOtherPage.html would be loaded with the data retrived from pants(...) written and displayed in it.

I know that a page can be written on the fly and I am using this method at the moment, but I have thisPage.html loaded into an <iframe> that resizes depending on the page content. However the 'on-the-fly' created page doesn't resize the <iframe> no matter how hard I try.

So, to kill two birds with one stone so to speak, parsing the data to an another html file would resize the <iframe> when the new page is loaded and be easier to make alterations to, if needed.

Pantyboy
ASKER CERTIFIED SOLUTION
Avatar of ren_b
ren_b
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
minor typo: ``view a <strong>woman reading</strong>''
Hi ren_b

This works. However, just a couple of questions.

1. Can I alter the document.writeln() statement to document.write() so that the page can be laid out differently?

2. Can I use the data retrieved in pants[1] as the document title?


Pantyboy
1. ya you can change the document.writeln to whatever you want, that was just an example.
2. document.title = pants[1]
Hi ren_b

Thanks for the help. This solves m' problem.

Big up

Pantyboy :)