View Full Version : Java Scrip Help...


DanG
11-03-2009, 01:44 PM
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:
<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:

<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
11-03-2009, 04:10 PM
how about using the visibility property?if (
SOMETHING
)
{ document.getElementById("ID").style.visibility = "hidden";
}

DanG
11-04-2009, 07:47 AM
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.

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

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

ajetrumpet
11-10-2009, 12:28 AM
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.

<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:<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
11-10-2009, 07:49 PM
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!