Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ajax] Jak zrobic aby po kliknieciu w link pod spodem pojawila sie tresc danego div-a lub strony html, wiem banal, ale nie moge dojsc :)
jaskooo
post
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 24.04.2004
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Witam wszystkich.
Czarna dziura.

Sprawa wygląda tak:

Chciałbym aby po kliknięciu w link pod spodem wyświetlała sie zawartość odpowiedniego do linka DIV-a lub strony HTML, bez przeładowywania strony.

Wiem, ze to jest podstawa Ajax-a i mógłbym przekopiować gotowy skrypt, ale chciałbym sie nauczyć jak to działa.


Strona wyglada nastepujaco:

galeria.php

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5. <link rel="stylesheet" type="text/css" href="style.css" />
  6. <title>Galeria</title>
  7.  
  8.  
  9. </head>
  10. <div id="main">
  11.  
  12. <div>
  13. <li><a href="pierwsza.php">Pierwsza</a></li>
  14. <li>href="drugie.php">Druga</a></li>
  15. </div>
  16.  
  17.  
  18.  
  19. </div>
  20.  
  21. </body>
  22. </html>



pierwsza.php
  1.  
  2.  
  3. <?php
  4.  
  5. $dir_arr = scandir('pierwsza/');
  6. array_shift($dir_arr);
  7. array_shift($dir_arr);
  8. array_shift($dir_arr);
  9. foreach($dir_arr as $file)
  10. {
  11.  
  12. echo "<a href=\"\" onclick=\"window.open('zdjecia/$file', '$file','menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no')\"><img style='width: 100px;' src=\"zdjecia/$file\"></img></a>";
  13.  
  14.  
  15. }
  16.  
  17.  
  18.  
  19.  
  20. ?>
  21. </body>
  22. </html>


druga.php
  1. <?php
  2.  
  3. $dir_arr = scandir('druga/');
  4. array_shift($dir_arr);
  5. array_shift($dir_arr);
  6. array_shift($dir_arr);
  7. foreach($dir_arr as $file)
  8. {
  9.  
  10. echo "<a href=\"\" onclick=\"window.open('zdjecia/$file', '$file','menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=".$szer.", height=".$wys."')\"><img style='width: 100px;' src=\"zdjecia/$file\"></img></a>\n";
  11.  
  12. }
  13.  
  14.  
  15.  
  16.  
  17. ?>




Proszę o pomoc (IMG:http://forum.php.pl/style_emoticons/default/exclamation.gif) !!


Z gory dziekuje (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
abc667
post
Post #2





Grupa: Zarejestrowani
Postów: 229
Pomógł: 0
Dołączył: 29.05.2007

Ostrzeżenie: (0%)
-----


  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <title>...</title>
  3. <script type="text/javascript" src="advajax.js"></script>
  4. <script type="text/javascript">
  5.  
  6. function dd(plik)
  7. {
  8. advAJAX.get({
  9. url : plik,
  10. mimeType: 'text/html',
  11. onSuccess : function(obj) { document.getElementById("cnt").innerHTML = obj.responseText; }
  12. });
  13.  
  14. }
  15.  
  16.  
  17. </head>
  18.  
  19. <div id="cnt">
  20.  
  21. </div>
  22. <a href="#" onclick="dd('plik.php'); return false;">pobierz</a>
  23. </body>
  24. </html>

ok, masz to co napisałem w poście wcześniej

Ten post edytował abc667 23.06.2007, 12:17:35
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 5.10.2025 - 10:02