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

Menu Question

Status
Not open for further replies.

TheCandyman

Technical User
Sep 9, 2002
761
US
Im a so-so java programer, so i was wondering if this would be possible and if you could point me to some examples.

On a page, i have FAQ section, the questions are all at the top. If you click one, it jumps to the answer below... ya i know real tough.. but i was wondering if i can make it so when the question was clicked it would jump to the answer but have it highlighted. Maybe a diff color, or table around it. anyone ever heard of this? Or am i smokin to many shrooms, muhaha.

 
No replys, that's not good.

How about if they click on a link, have a pic appear? I searched around and can't find any examples
 
let's try the below example, is this u wanna?

Code:
<html>
<head>
<script language="JavaScript">
var oldId="";
function go(newId){
if (oldId!="")
document.getElementById(oldId).style.color="#000000";
document.getElementById(newId).style.color="#ff0000";
oldId=newId;
window.location="#ans"+newId.charAt(1);
}
</script>
</head>

<body>
<a name="top"></a>
<a href="javascript:go('a1');">
1.&nbsp;question1
</a><br>
<a href="javascript:go('a2');">
2.&nbsp;question2
</a><br>
<a href="javascript:go('a3');">
3.&nbsp;question3
</a><br>
.<p>.<p>.<p>.<p>.<p>.<p>
<span id=a1>
<a name="ans1">
1.&nbsp;question1<br>&nbsp;answer1
</a>
</span>
<br><a href="#top">Top</a><p>
<span id=a2>
<a name="ans2">
2.&nbsp;question2<br>&nbsp;answer2
</a>
</span>
<br><a href="#top">Top</a><p>
<span id=a3>
<a name="ans3">
3.&nbsp;question3<br>&nbsp;answer3
</a>
</span>
<br>
<a href="#top">Top</a><p>
</body>
</html>
 
That works great!! I noticed it only works up to 9, how to do make it go higher? i tried

<a href="javascript:go('a11');">Why do sockets fail?</a><br>
...
...
<span id=a11><a name="ans11">
Why do sockets fail?
<br></b></span>


but it doesn't jump to anything... any suggestions?
 
i'm sorry my bad eg., let's try to modify this

Code:
<html>
<head>
<script language="JavaScript">
var oldId="";
function go(newId){
if (oldId!="")
document.getElementById(oldId).style.color="#000000";
document.getElementById(newId).style.color="#ff0000";
oldId=newId;
window.location="#"+newId;
}
</script>
</head>

<body>
<a name="top"></a>
<a href="javascript:go('a1');">
1.&nbsp;question1
</a><br>
<a href="javascript:go('a2');">
2.&nbsp;question2
</a><br>
<a href="javascript:go('a3');">
3.&nbsp;question3
</a><br>
.<p>.<p>.<p>.<p>.<p>.<p>
<span id=a1>
1.&nbsp;question1<br>&nbsp;answer1
</span>
<br><a href="#top">Top</a><p>
<span id=a2>
2.&nbsp;question2<br>&nbsp;answer2
</span>
<br><a href="#top">Top</a><p>
<span id=a3>
3.&nbsp;question3<br>&nbsp;answer3
</span>
<br>
<a href="#top">Top</a><p>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top