Java Scrip Help... (1 Viewer)

DanG

Registered User.
Local time
Today, 13:06
Joined
Nov 4, 2004
Messages
477
I am working on a webpage that has 3 columns, the first column is a button, the second one is an image (with 4 hotspots) and the third column is text.

When the user clicks on a button (col#1) an image in col#2 shows up and when one of the four hotspots is chosen on the image the related text pops up.

The problem I am having is that when I click on the button (that was pressed in the beginning) I want it to hide both the image in col#2 AND the text in col#3. Currently it just hides the image and not the text in col#3.

I understand why it does this, I am just not sure how to fix it.

Main script:
Code:
<script type="text/javascript">
function toggleMe(a){
var e=document.getElementById(a);
if(!e)return true;
if(e.style.display=="none"){
e.style.display="block"
}
else{
e.style.display="none"
}
return true;
}
</script>
The button code calls to the image div and then the image hotspots call to the related text divs.
Button code:
Code:
<input type="button" onclick="return toggleMe('BigSky')" value="Big Sky" style="width:150">

I hope this makes sense to someone. I imagine the code needs some logic, but I have actually never used java before :)
 

ajetrumpet

Banned
Local time
Today, 15:06
Joined
Jun 22, 2007
Messages
5,638
how about using the visibility property?
PHP:
if (
   SOMETHING
)
{ document.getElementById("ID").style.visibility = "hidden";
}
 

DanG

Registered User.
Local time
Today, 13:06
Joined
Nov 4, 2004
Messages
477
Thank you for the assistance.

Again, I have never used java before so don't laugh at me too hard. But going with you idea, I named the buttton "BSBut" and then I wrapped a div named "test" around my text from col#3. So the plan would be that if the button (BSBut) was false my div ("test") would be set to "display:none".

The code I put together below doesn't work, but at least it's a starting point.

Code:
<script type="text/javascript">
var but=document.getElementById("name")
var BSdiv=document.getElementById("ID")

if*( but= "BSBut") 
{*BSdiv.style.display*=*"none"; 
}* 
</script>
 

ajetrumpet

Banned
Local time
Today, 15:06
Joined
Jun 22, 2007
Messages
5,638
Thank you for the assistance.

Again, I have never used java before so don't laugh at me too hard. But going with you idea, I named the buttton "BSBut" and then I wrapped a div named "test" around my text from col#3. So the plan would be that if the button (BSBut) was false my div ("test") would be set to "display:none".

The code I put together below doesn't work, but at least it's a starting point.

Code:
<script type="text/javascript">
var but=document.getElementById("name")
var BSdiv=document.getElementById("ID")

if*( but= "BSBut") 
{*BSdiv.style.display*=*"none"; 
}* 
</script>

i have no clue what you're doing, but let me help you out as to what I think you want:
PHP:
<script type="text/javascript">

var but=document.getElementById("name").value
var BSdiv=document.getElementById("ID").value

if (but = "BSBut") {  //BSBut has to be a value . if that's an element,
                                  // you need to use code as above
BSdiv.style.visibility = "hidden"; 
}
</script>
 

DanG

Registered User.
Local time
Today, 13:06
Joined
Nov 4, 2004
Messages
477
Thank you, I will try apply your suggestion, it may take a while as this is a side project and I just got hit with another project.

But I will let you know how it goes!
 

Users who are viewing this thread

Top Bottom