kelemvor
09-22-2003, 09:25 PM
Howdy,
I came upon this script at dynamicdrive.com:
http://www.dynamicdrive.com/dynamicindex17/comboviewer.htm
It has the elements of what I want to do but it's not exactly what I need. But they do some coding with things I've never seen before so I'm not sure where to begin to modify it.
THEIR script works off a Combo Box and some hidden DIVs. When you select somethign from the box, it shows/hides the DIVs so you see the info about the item you selected.
MY NEED is a script that does the same thing but instead of using a Combo Box, I need to use the onMouseover event with some hyperlinks. So when a user puts their mouse on link1, I want to show the div pertaining to image 1, then 2, etc.
Can you give me some help with where to begin? Or if it's easy enough, how to do this from scratch?
Thanks.
--Mike
Pasting in the code from DynamicDrive so you don't have to go to the link if you don't want....
HEADER INFO:
<style type="text/css">
.dropcontent{
width: 300px;
height: 140px;
border: 1px solid black;
background-color: #FFECC6;
display:block;
}
</style>
<script type="text/javascript">
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.dropcontent{display:none;}\n')
document.write('</style>\n')
}
function contractall(){
if (document.getElementById){
var inc=0
while (document.getElementById("dropmsg"+inc)){
document.getElementById("dropmsg"+inc).style.display="none"
inc++
}
}
}
function expandone(){
if (document.getElementById){
var selectedItem=document.dropmsgform.dropmsgoption.selectedIndex
contractall()
document.getElementById("dropmsg"+selectedItem).style.display="block"
}
}
if (window.addEventListener)
window.addEventListener("load", expandone, false)
else if (window.attachEvent)
window.attachEvent("onload", expandone)
</script>
BODY INFO:
<form name="dropmsgform">
<select name="dropmsgoption" size="1" style="width:300" onChange="expandone()">
<option selected>What is JavaScript?</option>
<option>Difference betwen Java and JavaScript</option>
<option>What is DHTML?</option>
</select>
<br>
<div id="dropmsg0" class="dropcontent">
JavaScript.....
</div>
<div id="dropmsg1" class="dropcontent">
Java is completely different from JavaScript.....</div>
<div id="dropmsg2" class="dropcontent">
DHTML is the embodiment.....</div>
</form>
I came upon this script at dynamicdrive.com:
http://www.dynamicdrive.com/dynamicindex17/comboviewer.htm
It has the elements of what I want to do but it's not exactly what I need. But they do some coding with things I've never seen before so I'm not sure where to begin to modify it.
THEIR script works off a Combo Box and some hidden DIVs. When you select somethign from the box, it shows/hides the DIVs so you see the info about the item you selected.
MY NEED is a script that does the same thing but instead of using a Combo Box, I need to use the onMouseover event with some hyperlinks. So when a user puts their mouse on link1, I want to show the div pertaining to image 1, then 2, etc.
Can you give me some help with where to begin? Or if it's easy enough, how to do this from scratch?
Thanks.
--Mike
Pasting in the code from DynamicDrive so you don't have to go to the link if you don't want....
HEADER INFO:
<style type="text/css">
.dropcontent{
width: 300px;
height: 140px;
border: 1px solid black;
background-color: #FFECC6;
display:block;
}
</style>
<script type="text/javascript">
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.dropcontent{display:none;}\n')
document.write('</style>\n')
}
function contractall(){
if (document.getElementById){
var inc=0
while (document.getElementById("dropmsg"+inc)){
document.getElementById("dropmsg"+inc).style.display="none"
inc++
}
}
}
function expandone(){
if (document.getElementById){
var selectedItem=document.dropmsgform.dropmsgoption.selectedIndex
contractall()
document.getElementById("dropmsg"+selectedItem).style.display="block"
}
}
if (window.addEventListener)
window.addEventListener("load", expandone, false)
else if (window.attachEvent)
window.attachEvent("onload", expandone)
</script>
BODY INFO:
<form name="dropmsgform">
<select name="dropmsgoption" size="1" style="width:300" onChange="expandone()">
<option selected>What is JavaScript?</option>
<option>Difference betwen Java and JavaScript</option>
<option>What is DHTML?</option>
</select>
<br>
<div id="dropmsg0" class="dropcontent">
JavaScript.....
</div>
<div id="dropmsg1" class="dropcontent">
Java is completely different from JavaScript.....</div>
<div id="dropmsg2" class="dropcontent">
DHTML is the embodiment.....</div>
</form>