...

View Full Version : Show and/or Hide Div layer on click!?!?



pixelEngine
03-24-2005, 04:23 PM
OK... i have a div layer that i would like to be able to show/hide onClick..... Here is what I have so far....

<script type="text/javascript">
function HideOrShowDiv(lyr) {
if (lyr.style.display=='none'){
alert("showing");
lyr.style.display='block';
}else{
alert("hiding");
lyr.style.display='none';
}
}
</script>


Here is the page I am working on.... http://www.tiredealersites.com/experiments/css/

I want to be able to click on the "Details" to show or hide the details for the item. The way it is right now it just hides the details button (because i am passing 'this' in the function to hide/show), so i need to somehow target the div with the details in it?! <a href="#" onClick="HideOrShowDiv(this)">view details</a>

I hope this make some sense, any help would be greatly appreciated!!

Cheers. :thumbsup:

afru
03-24-2005, 04:37 PM
Hi,

Wrap your "Details" into some other div with id "detailsdiv1" and send "1" as parameter to your function. Likewise change other items also.

Also you need to change your function like this.



function HideOrShowDiv(itemno) {
var lyr=document.getElementById('detailsdiv'+itemno);
if (lyr.style.display=='none'){
alert("showing");
lyr.style.display='block';
}else{
alert("hiding");
lyr.style.display='none';
}
}


Hope this will work for you...

Afru.

pixelEngine
03-24-2005, 04:43 PM
Got it, works.... Thanks Afru! :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum