I have a link that once clicked is suppose to make a div visible. So far it does but it only makes the div visible for a second then it returns to being invisible.

I gave the div the value display:none; in Css and the javascript gives it the value display:block; in the onlcick function. Here is my Html and Javascript

<script>
function blackBox()
{
document.getElementById("black_box").style.display='block';
document.getElementById("terms_and_agree").style.display='block';
}
</script>



<a href="" style="color:#3d3d3d;" onclick="blackBox()">Terms and Agreements</a>

How can I stop the div from only flashing??

I'm not on a PC to check, but I suspect you are having a postback and refreshing the page

The postback needs to be prevented.

Yeah, you need to change your onclick to = "blackbox();return false" to stop the link actually trying to fire. Its running the blackbox function and then reloading the href (the same page in this case).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.