Log in

View Full Version : Onclick Div that doesn't hide



bense18
04-19-2008, 06:00 PM
I am looking for a script for a contact list.

I want it to load in the same area, but be separate DIVs and be activated by click.
http://img386.imageshack.us/img386/3245/clickab8.jpg


For example. Click the envelope beside David Alpner's name, it loads a form to contact him. Click the envelope beside Mimi Polk Gitlin's name, it loads a contact form in the same DIV, and so on.

I could just use email addys on click, but to avoid spam, I want to try it this way. I don't want to use Iframes either, as there will be thousands of addresses added.

I've been searching and working for the past two hours and can't get it to work. Can anyone point me in the right direction?

Medyman
04-20-2008, 03:32 AM
If I understand you correctly, this should work:

Javascript (goes in the head):

<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>

CSS:

.contact { display:none; }

HTML:

<a href="#" onclick="toggle_visibility('david');"><img src="envelope.gif"></a>David Alper


<div class="contact" id="david">
<form>
...
</form>
</div>