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

Hyperlink to display pics and comments in parent frames? 1

Status
Not open for further replies.

rudo

Programmer
Jul 3, 2002
72
0
0
NL
Hi,
Could someone help me with following?
In one frame, I have a list with hyperlinks (code below) and when you click on a link a picture appears in another frame (main2). So far so good. At each hyperlink I would like to add a short comment to be displayed in a separate frame (country_name).

I tried to add the comment with the document.write method, like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"<html>
<head>
<title>African countries</title>
</head>

<body>
<font face="Verdana" size="2">
<ul>
<li><a target="main2" href="images/Africa/Algeria.jpg" onClick="parent.country_name.document.write('Algeria'.fontsize(5).bold())">Algeria</a><br></li>
<li><a target="main2" href="images/Africa/Angola.jpg" onClick="parent.country_name.document.write('Angola'.fontsize(5).bold())">Angola</a><br></li>
</ul>
</font>
</body>
</html>

My problem with this method is, is that once the first comment is displayed, the following is added to it, instead of replacing the first one. (I didn’t find a method to clear the old text, before writing the new comment.)

Alternatively I tried to display the comment in a text box (‘cntry’) I defined within the .htm-file that populates frame ‘country_name’, but could not find the correct code. This is one of the versions I tried out:

<li><a target="main2" href="images/Africa/Algeria.jpg"
onClick="input type='text' parent.country_name.document.form('cntry').value='Algeria'">Algeria</a><br></li>

All help with one of these two methods will be very appreciated!
 
Well there's several things you can do.

If there's a specific element in the country_name frame where you want the text to appear you can such the elements innerHTML attribute.

Assuming a div or even a span with an ID of say comment:
Code:
<div id="comment"></div>

Code:
parent.country_name.document.getElementById('comment').innerHTML='Algeria';

If you want to keep the text box version, you can do it to if you address it correctly. And remove the input type=text thing there as it is completely incorrect and does absolutely nothing there.
Code:
<form name="[red]mycommentform[/red]">
<input type="text" name='[blue]comments[/blue]' value="">
</form>

Code:
parent.country_name.document.forms[0].[blue]comments[/blue].value='Algeria';

or

parent.country_name.document.forms['[red]mycommentform[/red]'].[blue]comments[/blue].value='Algeria';

or even

parent.country_name.document.forms.[red]mycommentform[/red].[blue]comments[/blue].value='Algeria';




----------------------------------
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.
 
Hi Vacunita,

Great!!! The second method with the comment form works!!!
I won't tell you how much time I have spent searching for a solution ;-)
As for the division 'comment' solution, that did not work here. I don't know if it is because of my Firefox browser or something else, but I will still try this solution too, as it gives a more elegant result.
Thank you very, very much for helping me!!!
Kind greetings,
Rudo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top