Wednesday, April 18, 2007

show-hide DIV


suppose there are 10 divs in a page. you need to show each div while clicking the corresponding link

here is the
javascript

<script language="javascript" type="text/javascript" >
<!--
function showdiv(id)
{ for (var x = 1; x <= 10; x++)
{
var a='div_' + x;
document.getElementById(a).style.display = "none"
}
document.getElementById("div_" + id).style.display = ""
}
function hidediv ( id )
{
document.getElementById("div_" + id ).style.display = "none"
}
-->
</script>

and call the javascript inside an anchor tag like this onClick=showdiv(1)

No comments: