I want to create popup div(named linkdiv holding linkcontent div) on td click which is using this function:
function getLinks(lid) {
document.getElementById('linkdiv').style.display = "block";
document.getElementById('linkdiv').style.visibility = "visible";
document.getElementById('linkcontent').innerHTML = "<div align=center><img src='images/spacer.gif' border=0 height=280 width=10 alt=''><br><img src='images_v2/loading.gif' border=0 alt='Loading content'></div>";
var lurl = "viewlinksdiv.php?lid="+lid;
if(window.XMLHttpRequest) {
reql = new XMLHttpRequest;
} else if(window.ActiveXObject) {
reql = new ActiveXObject("Microsoft.XMLHTTP");
}
if(reql) {
reql.onreadystatechange = getLinkResp;
reql.open("GET",lurl,true);
reql.send(null);
} else {
alert("Your browser does not support XMLHttpRequest technology!");
doesNotSupport = false;
}
}
and the td is..
echo "
<tr>
<td width=240 height=20 align=\ "left\" valign=\ "top\" style=\ "cursor:hand;cursor:pointer;padding-top:".$pad. ";padding-bottom:5px\" onclick=\ "getLinks('".$mid. "');return:false;\"><b class='news_date'>".$mdate." ".$cname.$mpol.":</b>
<font class='news_title'>".$msectname."</font><br>
<font class='news_date'>".$moretext."</font>
</td>
</tr>\n";
and the div I want to show is
<div id="linkdiv">
<div id="linkdiv_body">
<div id="tapclose" align="right" onclick="closeLink()" alt="Close">X</div>
<div id="linkcontent" class="linkdiv_font"></div>
</div>
</div>
this function is working with a href element like
<a class="jslink" href="javascript:getLinks('3975')">link</a>
but doesn't work on td onclick element.
which is weird cause it's using the same function.
Anyone have any idea why this doesn't work?
Thanks.
td. You shouldn't close the"and use a<?php ?>tag instead to display the value, like in this accepted answer, solution 2console.log(lid)ingetLinks(lid)... You'll see if the function triggers and if the id passed is correct.