Forum Moderators: open

Message Too Old, No Replies

frustrated with creating definitions

         

jessboy

7:47 pm on Jul 5, 2004 (gmt 0)



Trying to create a section in site that should be very easy but not working for me. I'd like to create either one of two things:

i. have a list of services listed on one side of a table and when you click on the service name the description is displayed in other side of table. OR...

ii. have a list of services and when you click on the service name the description pops up.

I have been able to create ii. (with some strange code that doesn't use javascript) but cannot keep the definition on top. The first definition comes up on top but if you click on another definition is slips under the window. So I used
<onBlur="self.focus()">
to keep it on top, but the definition doesn't change when user clicks on a new list item and creates an awkward situation for the user --- having to close each definition window in order to access another definition.

I have all the definitions saved as individual files, so maybe I should be using embedded files? I'm sure this is a simple thing, I just can't seem to get it to work.

MichaelBluejay

3:12 am on Jul 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For (i), here's how you can dynamically change text on a page:

<HEAD>
<SCRIPT language=Javascript>
function showText(whichText) {
theText = new Array('apples','oranges','bananas');
document.getElementById('dynamic').innerHTML = theText[whichText];
}
</SCRIPT>
</HEAD>
<BODY>
<P><A href="#" onclick="showText(0)">One</A>
<P><A href="#" onclick="showText(1)">Two</A>
<P><A href="#" onclick="showText(2)">Three</A>
<HR>
<P>
<div id=dynamic></div>
</BODY>

dcrombie

10:19 am on Jul 6, 2004 (gmt 0)



Or if you want to support non-IE browsers:

document.getElementById('dynamic').firstChild.nodeValue = theText[whichText];

(assuming firstChild exists for an empty div - might want to check that ;))