raj_2006
08-27-2007, 08:39 AM
Hi All,
I have searched this forum and found a nice code.But the problem is that I want to use php/mysql inside the javascript function and also want to add a url(which is also coming from the db) against every banner.
Here is the javascript:
<script language="javascript" type="text/javascript">
<!--
var arrBanner = new Array();
//here i want to add the banners in array from the mysql db.
arrBanner[0] = 'ban/banner468x60.gif'
arrBanner[1] = 'ban/bcpc-banner-468x60.jpg'
function initSlideShow() {
var preLoad = new Array();
for (var i = 0; i < arrBanner.length; i++) {
preLoad[i] = new Image();
preLoad[i].src = arrBanner[i];
}
var rndId = Math.floor(Math.random()*arrBanner.length);
//here I want to add the urls of each banner
document.write('<img src="'+arrBanner[rndId]+'" name="SlideShow" id="SlideShow" width="468" height="60" />');
window.setInterval('runSlideShow()', slideShowSpeed);
} // initSlideShow.
function runSlideShow(){
rndId = Math.floor(Math.random()*arrBanner.length);
if (document.all){
document.images.SlideShow.style.filter = "blendTrans(duration=2)";
document.images.SlideShow.style.filter = "blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply() ;
}
document.images.SlideShow.src = arrBanner[rndId];
if (document.all){
document.images.SlideShow.filters.blendTrans.Play();
}
} // runSlideShow.
//initSlideShow();
//-->
</script>
<script>initSlideShow();</script>
Please suggest me how can i do it....I dont have much idea about using php/mysql inside the javascript...please help me out...
Thanks for your co-operation in advance.
Raj
I have searched this forum and found a nice code.But the problem is that I want to use php/mysql inside the javascript function and also want to add a url(which is also coming from the db) against every banner.
Here is the javascript:
<script language="javascript" type="text/javascript">
<!--
var arrBanner = new Array();
//here i want to add the banners in array from the mysql db.
arrBanner[0] = 'ban/banner468x60.gif'
arrBanner[1] = 'ban/bcpc-banner-468x60.jpg'
function initSlideShow() {
var preLoad = new Array();
for (var i = 0; i < arrBanner.length; i++) {
preLoad[i] = new Image();
preLoad[i].src = arrBanner[i];
}
var rndId = Math.floor(Math.random()*arrBanner.length);
//here I want to add the urls of each banner
document.write('<img src="'+arrBanner[rndId]+'" name="SlideShow" id="SlideShow" width="468" height="60" />');
window.setInterval('runSlideShow()', slideShowSpeed);
} // initSlideShow.
function runSlideShow(){
rndId = Math.floor(Math.random()*arrBanner.length);
if (document.all){
document.images.SlideShow.style.filter = "blendTrans(duration=2)";
document.images.SlideShow.style.filter = "blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply() ;
}
document.images.SlideShow.src = arrBanner[rndId];
if (document.all){
document.images.SlideShow.filters.blendTrans.Play();
}
} // runSlideShow.
//initSlideShow();
//-->
</script>
<script>initSlideShow();</script>
Please suggest me how can i do it....I dont have much idea about using php/mysql inside the javascript...please help me out...
Thanks for your co-operation in advance.
Raj