Forum Moderators: open
I tried so many things without any luck like
odoc.getElementById('divVerMais_319').onclick='javascript:toggleDetails(319)'
id=ctl00_ContentPlaceHolder1_dlResultados_ctl05_InterDataList><SPAN><STRONG>Insolvente/Devedor:</STRONG> ABC Ltd <BR> <STRONG>Nif: </STRONG>504000000 </SPAN></SPAN><BR><SPAN style="DISPLAY: none" id=Details_319 runat="server"></SPAN>
<DIV style="TEXT-ALIGN: right" id=divVerMais_319 class=vermais runat="server"><A title="Ver detalhes do processo 574, " onclick=javascript:toggleDetails(319); href="javascript:void(0);">ver mais</A> </DIV></DIV></SPAN></SPAN><BR>
Can anyone help me?
Thanks a lot
Sam
What you want to do in your onclick is return false. this will stop the "real link" from navigating the page.
Second, although click events on divs, paragraphs, etc. WILL work, it's a better idea to put the event directly on the link. You can style a link to "fill out" the div.
On another note, spans are inline elements, divs are block. You can't put divs inside spans, but you can put spans inside divs.
Working example:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled</title>
<style type="text/css">
#div1 { width: 400px; margin:auto; TEXT-ALIGN: right; border: 1px solid #000000; }
#divVerMais_319 { width: 370px; height: 70px; display:block; padding: 50px 30px 30px 0; }
</style>
<script type="text/javascript">
window.onload=function() {
if (document.getElementById('divVerMais_319')) {
document.getElementById('divVerMais_319').onclick= function() { return toggleDetails(319) };
}
};
function toggleDetails (some_id) {
alert('You have sent ' + some_id + ' to this function.');
return false;
}
</script>
</head>
<body>
<div id="div1"><a href="alternate-content.html"
title="Ver detalhes do processo 574," id="divVerMais_319">ver mais</a> </div>
</body>
</html>
Could you help
Thanks and Regards
Sam