login  Naam:   Wachtwoord: 
Registreer je!
 Forum

php AND javascript (Opgelost)

Offline p1n0 - 04/09/2007 15:53
Avatar van p1n0Nieuw lid Hee hallo,

Ben bezig met een fotoalbum script, waarmee je door de foto;s kan bladeren zonder dat de gehele pagina reload. Zie gebruikte code

  1. <script language="javascript">
  2. var photos=new Array()
  3. var which=0
  4.  
  5. /*Change the below variables to reference your own images. You may have as many images in the slider as you wish*/
  6.  
  7. <?
  8. while ($rows2 = mysql_fetch_object($results2))
  9. {
  10. echo "photos[$foto]=\"nieuws_img/$rows2->foto\"";
  11. $foto = $foto + 1;
  12. }
  13. ?>
  14.  
  15. /*
  16. photos[0]="nieuws_img/8046_1188760028.jpg"
  17. photos[1]="nieuws_img/8491_1188759329.jpg"
  18. photos[2]="nieuws_img/563_1188760031.jpg"
  19. photos[3]="nieuws_img/6258_1188760035.jpg"
  20. photos[4]="nieuws_img/2349_1188760039.jpg"
  21. photos[5]="nieuws_img/195_1188760042.jpg"
  22. photos[6]="nieuws_img/7296_1188805487.jpg"
  23. */
  24. function backward(){
  25. if (which>0){
  26. window.status=''
  27. which--
  28. document.images.photoslider.src=photos[which]}}
  29.  
  30. function forward(){
  31. if (which<photos.length-1){
  32. which++
  33. document.images.photoslider.src=photos[which]}
  34. else window.status='End of gallery'}
  35. </script>


In commentaar heb ik wat foto's gezet, maar dat is natuurlijk niet dynamisch, maar werkt wel... de output van de query is precies hetzelfde maar php en werkt niet. Is dit op een of andere manier toch mogelijk?

Alvast bedankt!

3 antwoorden

Gesponsorde links
Offline lemoinet - 04/09/2007 16:03
Avatar van lemoinet PHP gevorderde eerste zo ik dit
  1. document.images.photoslider.src

in dit
  1. document.images['photoslider'].src

veranderen (ivm FF)
Offline Grayen - 04/09/2007 16:28
Avatar van Grayen PHP ver gevorderde
  1. <script type="text/javascript">
  2. var photos=new Array()
  3. var which=0
  4.  
  5. /*Change the below variables to reference your own images. You may have as many images in the slider as you wish*/
  6.  
  7. <?php
  8. if(mysql_num_rows($results2) > 0)
  9. {
  10. $iFoto = 0;
  11.  
  12. while(($aRow = mysql_fetch_assoc($results2)) !== false)
  13. {
  14. echo 'photos['.$iFoto.'] = "nieuws_img/'.$aRow['foto'].'"';
  15.  
  16. $iFoto++;
  17. }
  18. }
  19. ?>
  20.  
  21. /*
  22. photos[0]="nieuws_img/8046_1188760028.jpg"
  23. photos[1]="nieuws_img/8491_1188759329.jpg"
  24. photos[2]="nieuws_img/563_1188760031.jpg"
  25. photos[3]="nieuws_img/6258_1188760035.jpg"
  26. photos[4]="nieuws_img/2349_1188760039.jpg"
  27. photos[5]="nieuws_img/195_1188760042.jpg"
  28. photos[6]="nieuws_img/7296_1188805487.jpg"
  29. */
  30. function backward(){
  31. if (which>0){
  32. window.status=''
  33. which--
  34. document.images['photoslider'].src=photos[which]}}
  35.  
  36. function forward(){
  37. if (which<photos.length-1){
  38. which++
  39. document.images['photoslider'].src=photos[which]}
  40. else window.status='End of gallery'}
  41. </script>
Offline p1n0 - 05/09/2007 11:38
Avatar van p1n0 Nieuw lid @Grayen
sorry had je reactie nog niet gezien... thx anyway

had van deze regel
echo "photos[$foto]=\"nieuws_img/$rows2->foto\"";

deze regel gemaakt
echo "photos[$foto]=\"nieuws_img/$rows2->foto\"\n";

en toen werkte het!
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.199s