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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variable via <a href> tag

Status
Not open for further replies.

kosmokramer

Programmer
Sep 8, 2002
73
US
Does anyone know if you can pass a variable with the <a href> tag? What I want to do is I have a page that is set up with frames. The left frame has thumbnails in it, and when you click on the thumbnail, the full size picure pops up in the middle frame. I have done this just by passing a picture:

<a href=&quot;somepicture.jpg&quot; target=&quot;middle&quot;>
<img src=&quot;somepicureSmall.jpg&quot;>
</a>

The reason I set the link up this way is because I did not want to have to create a new html page for each image. I just wanted the image to show up. The problem I am running into is that I want to have a title under the picture. So, I am wondering if there is a way to within the <a href> tag send a variable which will put a caption under the image (perhaps a javascript document.write()...?)

Thanks!
 
Try this and tell me if it works :
Code:
<html>
<head>
<script language=&quot;javascript&quot;>
function ShowFullPicture(sourceImg) {
  var ImgName = sourceImg.id;
  var oMiddleFrame = window.frames(&quot;middle&quot;);
  oMiddleFrame.clear();
  oMiddleFrame.writeln (&quot;<IMG src='&quot; + ImgName + &quot;.jpg'/>&quot;);
  oMiddleFrame.writeln (ImgName);
}
</script>
</head>
<body>
      <img id=&quot;somepicure&quot; src=&quot;somepicureSmall.jpg&quot; style= &quot;CURSOR: hand&quot; onclick=&quot;ShowFullPicture(this);&quot;>
</body>
</html>
I'm not sure of this line :
Code:
var oMiddleFrame = window.frames(&quot;middle&quot;);
and I'm sure that
Code:
style= &quot;CURSOR: hand&quot;
will only work for IE browsers.
Water is not bad as long as it stays out human body ;-)
 
Hey. Thanks for the effort but unfortunately, it did not work.
 
Where is the error ? Water is not bad as long as it stays out human body ;-)
 
It does the same thing as before. The page that is created just has the picture. I am not even sure if the page is displayed in the same way as a regular page because when I right clicked to see the source, the option was greyed out. I had to go to frontpage to see what was actually going on. Frontpage showed that a page had indeed been created, but that it only contained the image. I am thinking it is something with the way the HTML language is set up, and there is no way around it. I might possibly just create a blank page and pass the variables to it instead of having an opening page which I replace with the image (possibly with the document.write() you gave me).

P.S. To see what I am talking about, the page is located at
 
Alright, I figured out what the problem was, and have fixed it. The only problem now is that when I click on any of the other pictures, it appends them to the page without clearing out the page first.

This is how I solved the problem :
<head>
<script language=&quot;javascript&quot;>
function ShowFullPicture(sourceImg)
{
var ImgName = sourceImg.id;
var description = sourceImg.title;
var oMiddleFrame = parent.window.middle;
oMiddleFrame.document.clear();
oMiddleFrame.document.write (&quot;<center><IMG src='&quot; + ImgName + &quot;.jpg'></center>&quot;);
oMiddleFrame.document.write (&quot;<br><center>&quot; + description + &quot;</center>&quot;);
}
</script>
</head>

the call looks like this:

<img id=&quot;photos_files/somepicture&quot; title=&quot;Description goes here&quot; src=&quot;photos_files/somepictureSmall.jpg&quot; onClick=&quot;ShowFullPicture(this);&quot;>

Any suggestions on how to clear the page so that only one picture shows up at a time?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top