I have this code for my drupal body with the php code Text Format:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<img id="thisImg" alt="img" src="http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/ads1.jpg"/>
<script type="text/javascript">
var myImage = new Array();
ctr = 0;
$(function(){
<?php
$log_directory = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/';
foreach(glob($log_directory.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory2 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery2/';
foreach(glob($log_directory2.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory3 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery3/';
foreach(glob($log_directory3.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory4 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery4/';
foreach(glob($log_directory4.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory5 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery5/';
foreach(glob($log_directory5.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory6 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery6/';
foreach(glob($log_directory6.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory7 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery7/';
foreach(glob($log_directory7.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory8 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery8/';
foreach(glob($log_directory8.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
console.log(myImage);
var thisId=0;
window.setInterval(function(){
$('#thisImg').attr('src',myImage[thisId]);
thisId++; //increment data array id
if (thisId==ctr) thisId=0; //repeat from start
},2000);
});
</script>
when I try to run this code in php file alone.
/var/www/unplay/trytoplay.php
it works fine. but when I try to write it in drupal body. it didt works. then I try to run my console and it says:
Uncaught TypeError: Object [object Object] has no method 'tinyNav' main-menu.jsmxywgd:85
Uncaught TypeError: Object [object Object] has no method 'cycle'
I try to install tinyNav but nothing happen. Thanks for the help.
try to update your jquery. you can refer to this link https://drupal.org/project/jquery_update
I try this with no jquery.
<img id="thisImg" alt="img" src="../fastcat.com.ph/sites/all/themes/impact_theme/images/ads1.jpg"/>
<script type="text/javascript">
var dataArray=new Array();
dataArray[0]="images/img1.png";
dataArray[1]="images/img2.png";
dataArray[2]="images/img3.png";
dataArray[3]="images/img0.png";
var myImage = new Array();
ctr = 0;
<?php
$log_directory = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/';
foreach(glob($log_directory.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory2 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery2/';
foreach(glob($log_directory2.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory3 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery3/';
foreach(glob($log_directory3.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory4 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery4/';
foreach(glob($log_directory4.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory5 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery5/';
foreach(glob($log_directory5.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory6 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery6/';
foreach(glob($log_directory6.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory7 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery7/';
foreach(glob($log_directory7.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory8 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery8/';
foreach(glob($log_directory8.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
var thisId=0;
setInterval(function(){
document.getElementById("thisImg").src=myImage[thisId];
// document.write(myImage[thisId]);
thisId++; //increment data array id
if (thisId==ctr) thisId=0; //repeat from start
},2000);
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.