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:
  1. <script>  
  2.   
  3. var g_nExpando=0;  
  4. // To make the cross clickable in every browser  
  5. function putItemInState(n,bState)  
  6. {  
  7.    var oItem,oGif;  
  8.       oItem=document.getElementById("descr"+n);  
  9.    oGif=document.getElementById("expandoGif"+n);  
  10.      
  11.    if (bState=='toggle')  
  12.      bState=(oItem.style.display=='block');  
  13.   
  14.    if(bState)  
  15.    {  
  16.        bState=(oItem.style.display='none');  
  17.        bState=(oGif.src='images/cross.gif');  
  18.    }  
  19.    else  
  20.    {  
  21.        bState=(oItem.style.display='block');  
  22.        bState=(oGif.src='images/noncross.gif');  
  23.    }  
  24. }  
  25.   
  26.   
  27.   
  28. function expand(nItem)  
  29. {  
  30.     putItemInState(nItem,'toggle');  
  31. }  
  32.   
  33.   
  34. function expandAll()  
  35. {  
  36.     if (!g_nExpando)  
  37.     {  
  38.         document.all.chkFlag.checked=false;  
  39.         return;  
  40.     }  
  41.     var bState=!document.all.chkFlag.checked;  
  42.     for(var i=0; i<g_nExpando; i++)  
  43.         putItemInState(i,bState);  
  44. }  
  45.   
  46. </script>  
php:
  1. //Expanding area  
  2. print("<tr><td class=chs colspan=11><div id=\"descr$id\" style=\"display: none;\"><table width=100%>");  
  3.     print("<tr><td><b>Részletek:</b></td>\n");  
  4.         print("<td class=ttable_col2><a href=\"details.php?");  
  5.       if ($variant == "mytorrents")  
  6.         print ("returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&amp;");  
  7.       print ("id=$id");  
  8.       if ($variant == "index")  
  9.         print ("&amp;hit=1");  
  10.       print ("\" title=\"" . $dispname . "\"><b>" . CutName($dispname$char = 100) .  
  11.         "</b></a>\n");  
  12.   
  13.         print("<tr><td><b>Rövid leírás:</b></td>\n");  
  14.         print("<td>$bbcode</td>\n");  
  15.             if($row["privacy"] == "strong" && get_user_class() < UC_JMODERATOR AND $CURUSER["id"] != $row["owner"]){  
  16.             print("</tr><tr><td><b>Added By:</b></td><td>Anonymous</td></tr><tr><td><b>Comments</b></td>\n");  
  17.             }else{  
  18.             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");  
  19.             }  
  20.         print("<td>There are <b><a href=\"torrents-details.php?id=$id#startcomments\">" . $row["comments"] . "</a></b> comments for this file.\n");  
  21.         print("</td>\n");  
  22.         print("</tr><tr><td><b>Status:</b></td>\n");  
  23.         print("<td>\n");  
  24.   
  25.         if ($row['seeders'] == 0 && $row['leechers'] == 0) {  
  26.             // no seeders/leechers = innactive  
  27.             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).';  
  28.         } elseif($row['seeders'] == 0 && $row['leechers']) {  
  29.             // some leechers but no seed = very bad  
  30.             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.';  
  31.         } elseif($row['seeders'] < 2) {  
  32.             // few seeds = poor  
  33.             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.';  
  34.         } else {  
  35.             // working fine  
  36.             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.';  
  37.         }  
  38.         //speed mod  
  39.         $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__);   
  40.         if ($rowTmp = mysql_fetch_row($resSpeed))  
  41.             list($seedersTmp,$leechersTmp) = $rowTmp;    
  42.         if ($seedersTmp >= 1 && $leechersTmp >= 1){   
  43.            $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__);   
  44.            $a = mysql_fetch_assoc($speedQ);   
  45.            $totalspeed = mksize($a["totalspeed"]) . "/s";   
  46.         }   
  47.         else   
  48.         $totalspeed = "Torrent inactive";    
  49.             print("<tr><td><b>Total Speed:</b></td>\n");  
  50.             print("<td><b><font color=green>");  
  51.             echo $totalspeed;  
  52.             print("</font></b></td></tr>");//speed end  
  53.   
  54.         print("</td></tr></table>\n");  
  55.   
  56.   
  57.     print("<table cellspacing=2 cellpadding=2 border=0 class=inposttable width=100%>  
  58.         <colgroup>  
  59.           <col width=20%>  
  60.           <col width=80%>  
  61.         </colgroup>  
  62.         <tr><td align=left border=\"1\"><img src=$cdtrayfront width=200 height=200></td><td>$bbcode</td></tr></td>  
  63.       ");  
  64. print("</td></tr></table></div></td>\n");  
  65. //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.