Passing variable to a second web page
What I want to do is pass the filename of a picture in Page1 to Page2 and display the picture on Page2. ASP, PHP, CSS are well beyond me.
In Page1, I have a hyperlink for Page2 as:
<a href="Page2.html?picturefilename.jpg">click here</a>
In Page 2:
2. How do I use the variable in an "<IMG" statement to show the picture?
Thanks for your help!
First, give the filename an associated variable name. Instead of "Page2.html?picturefilename.jpg", use "Page2.html?imgName=picturefilename.jpg".
Next, take a look at the following - nice little function that might help.
In the area where the picture is supposed to show on Page2.html, create a div and give it an ID, whatever you want to call it. I'll call it "imageHere".
Copy/paste the function from the above link in the bottom of Page2.html (just before the closing /body tag); immediately after it, write code that will use the function to grab the value of imgName and set it to a variable (call the variable "imageName").
Then use DOM to put the <img> tag inside the "imageHere" div.
document.getElementById("imageHere").innerHTML = '<img src="' + imageName + '">';
o . Q
_—__ "You live and you learn; or you don't live long." - Lazarus Long
Got it working!
Many, many thanks for your help!!
I got it working ... after many tries ... due to missing one character in the function.
Not only did I get it working but I learn quite a bit in the process. Loved the use of the Alert to test it out.
Saint Augustine, Florida
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)