ugrás a tartalomhoz

div tartalmának betöltése csak ha lenyílt...

lomajpurre · 2008. Jan. 5. (Szo), 08.31
Üdv!
Kellene egy kis segítség...
Van egy torrent oldalam, és úgy működik, ha rákattintassz a torrent nevére, alá kinyílik egy úly tábla és abban a torrent infok. Az a baj hogy mikor sok torrent van, mindnek a képeit, stb. betölti...
Azt szeretném hogy ami a div-en belül van csak kattitntáskor töltsön be, és amíg nincs betöltve, mondjuk egy gif animáció mennne(loading...)

javascript:

<script>

var g_nExpando=0;
// To make the cross clickable in every browser
function putItemInState(n,bState)
{
   var oItem,oGif;
      oItem=document.getElementById("descr"+n);
   oGif=document.getElementById("expandoGif"+n);
   
   if (bState=='toggle')
     bState=(oItem.style.display=='block');

   if(bState)
   {
       bState=(oItem.style.display='none');
       bState=(oGif.src='images/cross.gif');
   }
   else
   {
       bState=(oItem.style.display='block');
       bState=(oGif.src='images/noncross.gif');
   }
}



function expand(nItem)
{
    putItemInState(nItem,'toggle');
}


function expandAll()
{
    if (!g_nExpando)
    {
        document.all.chkFlag.checked=false;
        return;
    }
    var bState=!document.all.chkFlag.checked;
    for(var i=0; i<g_nExpando; i++)
        putItemInState(i,bState);
}

</script>

php:

//Expanding area
print("<tr><td class=chs colspan=11><div id=\"descr$id\" style=\"display: none;\"><table width=100%>");
	print("<tr><td><b>Részletek:</b></td>\n");
		print("<td class=ttable_col2><a href=\"details.php?");
      if ($variant == "mytorrents")
        print ("returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&amp;");
      print ("id=$id");
      if ($variant == "index")
        print ("&amp;hit=1");
      print ("\" title=\"" . $dispname . "\"><b>" . CutName($dispname, $char = 100) .
        "</b></a>\n");

		print("<tr><td><b>Rövid leírás:</b></td>\n");
		print("<td>$bbcode</td>\n");
			if($row["privacy"] == "strong" && get_user_class() < UC_JMODERATOR AND $CURUSER["id"] != $row["owner"]){
			print("</tr><tr><td><b>Added By:</b></td><td>Anonymous</td></tr><tr><td><b>Comments</b></td>\n");
			}else{
			print("</tr><tr><td><b>Added By:</b></td><td><a href=account-details.php?id=" . $row["owner"] . ">" . (isset($row["username"]) ? htmlspecialchars($row["username"]) : "<i>(unknown)</i>") . "</a></td></tr><tr><td><b>Comments</b></td>\n");
			}
		print("<td>There are <b><a href=\"torrents-details.php?id=$id#startcomments\">" . $row["comments"] . "</a></b> comments for this file.\n");
		print("</td>\n");
		print("</tr><tr><td><b>Status:</b></td>\n");
		print("<td>\n");

		if ($row['seeders'] == 0 && $row['leechers'] == 0) {
			// no seeders/leechers = innactive
			echo '<font color=#808080><b>INACTIVE</b></font>- This release is most probably dead (<b>' . $row['seeders'] . '</b> seeds and <b>' . $row['leechers'] . '</b> leechers).';
		} elseif($row['seeders'] == 0 && $row['leechers']) {
			// some leechers but no seed = very bad
			echo '<font color=#CC0000><b>CAUTION</b></font>- The release is active (<b>' . $row['leechers'] . '</b>)but there are no complete versions for the file availble.';
		} elseif($row['seeders'] < 2) {
			// few seeds = poor
			echo '<font color=#808000><b>POOR</b></font>- This release is active but there are only <b>' . $row['seeders'] . '</b> seeds. This release may be slow to download.';
		} else {
			// working fine
			echo '<font color=#008000><b>GOOD</b></font>- This release is active (<b>' . $row['seeders'] . '</b> seeds and <b>' . $row['leechers'] . '</b> leechers) and should download within a few hours.';
		}
		//speed mod
		$resSpeed = mysql_query("SELECT seeders,leechers FROM torrents WHERE $where visible='yes' and id = $id ORDER BY added DESC LIMIT 15") or sqlerr(__FILE__, __LINE__); 
		if ($rowTmp = mysql_fetch_row($resSpeed))
			list($seedersTmp,$leechersTmp) = $rowTmp;  
		if ($seedersTmp >= 1 && $leechersTmp >= 1){ 
		   $speedQ = mysql_query("SELECT (t.size * t.times_completed + SUM(p.downloaded)) / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS totalspeed FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' AND p.torrent = '$id' GROUP BY t.id ORDER BY added ASC LIMIT 15") or sqlerr(__FILE__, __LINE__); 
		   $a = mysql_fetch_assoc($speedQ); 
		   $totalspeed = mksize($a["totalspeed"]) . "/s"; 
		} 
		else 
		$totalspeed = "Torrent inactive";  
			print("<tr><td><b>Total Speed:</b></td>\n");
			print("<td><b><font color=green>");
			echo $totalspeed;
			print("</font></b></td></tr>");//speed end

		print("</td></tr></table>\n");


	print("<table cellspacing=2 cellpadding=2 border=0 class=inposttable width=100%>
        <colgroup>
          <col width=20%>
          <col width=80%>
        </colgroup>
        <tr><td align=left border=\"1\"><img src=$cdtrayfront width=200 height=200></td><td>$bbcode</td></tr></td>
      ");
print("</td></tr></table></div></td>\n");
//End Expanding Area
A segítséget előre is köszönöm!
 
1

és mi a kérdés?

rrd · 2008. Jan. 5. (Szo), 11.03
Már csak az nem világos, hogy mi a kérdés. Ha dinamikusan akarsz a szervertől adatokat kapni akkor ahhoz ajax kell. A te js kódodban nyoma sincs neki.
2

jquery.load

Jano · 2008. Jan. 5. (Szo), 13.32
Használj jQuery-t és abból a jquery.load()-dal könnyen megoldhatod.