dipps
Goto Top

Mit Perl und JavaScript aller 5 sek. Bild ändern

Mit Perl und JavaScript aller 5 sek. Bild ändern

Hallo ich habe eine Perlseite (mit Templets) und möchte in einem Templet das Bild aller 5 sek ändern mit Java Script am besten.
das bild wird folgender massen am anfang geladen:

<%
  require "../4flex/plugins/bild_startseite/plugin.pl";  

  my $imgtempl="<img src=\"##IMAGE1##\" width=\"350\" height=\"##HEIGHT1##\" border=\"1\" alt=\"##ALT1##\" name=\"testbild\">";  
  my ($imghtml, $imgid)=&zufallsbild($dbh, $cgi, 95, $imgtempl);
%>
....
<% print $imghtml; %>

nun soll nach 5sek ein neues zufälliges bild an diese stelle wie kann ich das am besten machen?

Content-Key: 98715

Url: https://administrator.de/contentid/98715

Ausgedruckt am: 29.03.2024 um 13:03 Uhr

Mitglied: Dipps
Dipps 10.10.2008 um 12:18:18 Uhr
Goto Top
Danke für die viele Hilfe habe es jetzt entlich selbst irgendwie geschaft. Für alle die mal das selbe Problem haben der Code:

<%
  require "../4flex/plugins/bild_startseite/plugin.pl";  

  my $imgtempl="<img src=\"##IMAGE1##\" width=\"350\" height=\"##HEIGHT1##\" border=\"1\" alt=\"##ALT1##\" id=\"imgbild\">";  
  my ($imghtml, $imgid)=&zufallsbild($dbh, $cgi, 95, $imgtempl);
%>
....
<% print $imghtml; %>

<script language="JavaScript">  

setTimeout("img_autoreload('imgbild')", 5000);  
                        var image;
                        var image_url=new Array();

<%
for(my $i = 0; $i <= 200; $i++) {
 




  require "../4flex/plugins/bild_startseite/plugin.pl";  

  my $imgtempl="##IMAGE1##";  
  my ($imghtml, $imgid)=&zufallsbild($dbh, $cgi, 95, $imgtempl);

print "image_url[$i] =\"$imghtml\";\n";  
}

%>





                        function img_autoreload(id)
                        {
image = document.getElementById(id);

                        


var x =  Math.floor((Math.random() * 201));


image.src = image_url[x-1];
                                
setTimeout("img_autoreload('imgbild')", 5000);  
                        }
                </script>