/    Sign up×
Community /Pin to ProfileBookmark

banner rotation…plz help

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-468×60.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

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@Arty_EffemAug 27.2007 — 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.
[/QUOTE]
You may have seen that code posted on this forum, but nobody will recommend it.

The statement[CODE]
if (document.all){
document.images.SlideShow.style.filter =[/CODE]
[/QUOTE]
condemns it to generate errors on anything but I.E.

Also fading transitions are fine for visual slideshows, but less advisable for image links, as the point at which the href changes may be unclear.

Any script calling itself a 'banner rotator' will provide the facility to specify URLs.

Generating the parameters with PHP is a matter for another forum.
Copy linkTweet thisAlerts:
@JPnycAug 27.2007 — not so, it will only generate an error in Opera. I believe Opera is the only other browser that understands document.all. Gecko browsers will fail the test and never see that code.

To allow for Opera change the test to :

if (document.all&&!window.opera)
Copy linkTweet thisAlerts:
@raj_2006authorAug 27.2007 — Hi

Thanks for your post.Yes I have looked that url and I want exact the same.

But my problem is that to use php mysql code inside the javascript function to call the banner filename + url values from the mysql db.

How can I do that?

Please suggest.

Thanks,

Raj
Copy linkTweet thisAlerts:
@raj_2006authorAug 27.2007 — not so, it will only generate an error in Opera. I believe Opera is the only other browser that understands document.all. Gecko browsers will fail the test and never see that code.[/QUOTE]

I have not understood couple of things here:

1.what is Gecko browsers?

2.If Opera understand document.all then is it necessary to write

if (document.all&&!window.opera)[/QUOTE]

Thanks

Raj
Copy linkTweet thisAlerts:
@JPnycAug 27.2007 — you can't put PHP inside JavaScript, you put the JavaScript inside the PHP, just like you would put HTML to be output to the page by the PHP file. you output it as a string literal, then concatenate it with the PHP statements.

Gecko browsers are Firefox, Netscape, Mozilla Sea monkey, etc. gecko is the name of their rendering engine. Yes, you should add &&!window.opera) to the test so that opera will skip over that code that it will not understand.

I'm going to move this to the PHP forum so you'll get the kind of answers you need .
Copy linkTweet thisAlerts:
@Arty_EffemAug 27.2007 — not so, it will only generate an error in Opera. I believe Opera is the only other browser that understands document.all. Gecko browsers will fail the test and never see that code.
[/QUOTE]
So. Gecko browsers do understand document.all in quirks mode.

My test would be:
[CODE]if(document.images[0].filters && document.images[0].filters.blendTrans)
... [/CODE]
Copy linkTweet thisAlerts:
@raj_2006authorAug 28.2007 — Hi

Thanks for moving the thread here.

I will try your suggestion means to use javascript inside php and will let you know about the o/p.

Thanks again

Raj
Copy linkTweet thisAlerts:
@raj_2006authorAug 29.2007 — Hi

I have started with this:

echo "<script language="javascript" type="text/javascript">

<?

echo "var slideShowSpeed = 5000"; // Set slideShowSpeed (milliseconds)

echo "var crossFadeDuration = 3"; // Duration of crossfade (seconds).

echo "var arrBanner = new Array()";

At this point i have become stucked how to make an php made javascript array...?

.................................................

.................................................

ALso how can i run a sql loop using a javascript variable which doesnot start with $.

Not getting any clue...........Please suggest me....

Regards,

Raj
Copy linkTweet thisAlerts:
@raj_2006authorAug 30.2007 — Can I have some hints only...?

Thanks

Raj
×

Success!

Help @raj_2006 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...