943,026 Members | Top Members by Rank

Ad:
Oct 2nd, 2009
-1

Photo Gallery Caption Won't Change

Expand Post »
Im not sure if this is a php problem or javascript, but since the actual photo gallery is run by javascript I'll post it here, sorry if its not though.

Everything works fine but when I click on another image to change the main image the caption wont change with it.

javascript Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. // Gallery script.
  3. // With image cross fade effect for those browsers that support it.
  4. // Script copyright (C) 2004-08 [url]www.cryer.co.uk[/url].
  5. // Script is free to use provided this copyright header is included.function LoadGallery(pictureName,imageFile,titleCaption,captionText)
  6. function LoadGallery(pictureName,imageFile)
  7. {
  8. var picture = document.getElementById(pictureName);
  9. if (picture.filters)
  10. {
  11. picture.style.filter="blendTrans(duration=1)";
  12. picture.filters.blendTrans.Apply();
  13. }
  14. picture.src = imageFile;
  15. if (picture.filters)
  16. {
  17. picture.filters.blendTrans.Play();
  18. }
  19. document.getElementById(titleCaption).innerHTML=captionText;
  20. }
  21. </script>
  22. <?
  23.  
  24. $con = mysql_connect('','','') or die('Error: ' . mysql_error());
  25. mysql_select_db('') or die('Error: ' . mysql_error());
  26.  
  27. $colNum = 1;
  28.  
  29. $sql = "SELECT * FROM `` ORDER BY `id` DESC LIMIT 0, 1";
  30. $query = mysql_query($sql,$con) or die('Error: ' . mysql_error());
  31. $table = '<table align="center" border="0" width="20px" cellpadding="0" cellspacing="0">';
  32. $table .= '<tr>';
  33. $num = 1;
  34. while ($r = mysql_fetch_array($query)) {
  35. $id=$r['id'];
  36. $name=$r['name'];
  37. $image=$r['image'];
  38. $caption=$r['caption'];
  39. $table .=<<<HTML
  40. <td>
  41. <table border=0 width=20px cellpadding=2 cellspacing=0>
  42. <tr>
  43. <td align=center>
  44. <img src=$image height=400px alt=$name id=showreel>
  45. <div id="showcaption">$caption</div>
  46. </td>
  47. </tr>
  48. </table>
  49. </td>
  50. HTML;
  51. if ($num == $colNum) {
  52. $table .= '</tr><tr>';
  53. $num = 0;
  54. }
  55. $num++;
  56. }
  57. $table .= '</table>';
  58.  
  59. echo $table;
  60.  
  61. mysql_close($con);
  62.  
  63. ?>
  64. </p>
  65.  
  66. <p class="century-gothic"><?
  67.  
  68. $con = mysql_connect('','','') or die('Error: ' . mysql_error());
  69. mysql_select_db('') or die('Error: ' . mysql_error());
  70.  
  71. $colNum = 12;
  72.  
  73. $sql = "SELECT * FROM `` ORDER BY `id` DESC LIMIT 0, 100";
  74. $query = mysql_query($sql,$con) or die('Error: ' . mysql_error());
  75. $table = '<table align="center" border="0" width="20px" cellpadding="0" cellspacing="0">';
  76. $table .= '<tr>';
  77. $num = 1;
  78. while ($r = mysql_fetch_array($query)) {
  79. $id=$r['id'];
  80. $name=$r['name'];
  81. $image=$r['image'];
  82. $caption=$r['caption'];
  83. $table .=<<<HTML
  84. <td>
  85. <table border=0 width=20px cellpadding=2 cellspacing=0>
  86. <tr>
  87. <td align=center>
  88. <a href="#_self" onclick="LoadGallery('showreel','$image','showcaption','$caption')"><img src=$image height=30px alt=$name></a>
  89. </td>
  90. </tr>
  91. </table>
  92. </td>
  93. HTML;
  94. if ($num == $colNum) {
  95. $table .= '</tr><tr>';
  96. $num = 0;
  97. }
  98. $num++;
  99. }
  100. $table .= '</table>';
  101.  
  102. echo $table;
  103.  
  104. mysql_close($con);
  105.  
  106. ?>
The website Page: http://collmillsg.com/showreel.php
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Scottmandoo is offline Offline
61 posts
since Feb 2008
Oct 2nd, 2009
0

Re: Photo Gallery Caption Won't Change

Hi there,

At first glance I notice the original function is function LoadGallery(pictureName,imageFile,titleCaption,captionText) while yours is function LoadGallery(pictureName,imageFile) . Yet on line 88 you call the LoadGallery function with 4 parameters <a href="#_self" onclick="LoadGallery('showreel','$image','showcaption','$caption')"> .

The JavaScript errors you keep getting on your site do mention the lack of a 'titleCaption' variable so perhaps it's a quick fix.

Again, try replacing

JavaScript Syntax (Toggle Plain Text)
  1. function LoadGallery(pictureName,imageFile)

with

JavaScript Syntax (Toggle Plain Text)
  1. function LoadGallery(pictureName,imageFile,titleCaption,captionText)

Hope that helps.

Good luck,

Traevel
Reputation Points: 16
Solved Threads: 16
Light Poster
Traevel is offline Offline
38 posts
since May 2009
Oct 3rd, 2009
0

Re: Photo Gallery Caption Won't Change

Hey thanks, yeah that was it.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Scottmandoo is offline Offline
61 posts
since Feb 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: document.getElementById not working in IE. Why?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Jscript Session time out





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC