/    Sign up×
Community /Pin to ProfileBookmark

Pictures Rotate!

I need help writing a script to make pictures rotate ever 5 seconds. I have no clue how to get the pictures to rotate every 5 seconds. I made a file called it pictures.js

[B][U]In the file I put[/U][/B] Picture[0]='<a href=”http://www.website.com/”><img src=”http://www.website.com/images/picture1_606x188.jpg” class=”imgBorder” alt=”website.com”></a>’
Picture[1]= and so on.

[B][/B]
[B][U]To end the file I used[/U][/B]
[FONT=&quot]function randomorder(targetarray, spacing) {[/FONT][FONT=&quot] var randomorder=new Array()[/FONT][FONT=&quot] var the_one[/FONT][FONT=&quot] var z=2[/FONT][FONT=&quot] for (i=0;i<targetarray.length;i++)[/FONT][FONT=&quot] randomorder[i]=i[/FONT][FONT=&quot] [/FONT][FONT=&quot] while (z<targetarray.length) {[/FONT][FONT=&quot] the_one=Math.floor(Math.random()*targetarray.length)[/FONT][FONT=&quot] if (targetarray[the_one]!=”_selected!”){[/FONT][FONT=&quot] document.write(targetarray[the_one]+spacing)[/FONT][FONT=&quot] targetarray[the_one]=”_selected!”[/FONT][FONT=&quot] z++[/FONT][FONT=&quot] }[/FONT][FONT=&quot] }[/FONT][FONT=&quot]}

[B][U]On my webpage to call the js I used[/U][/B]
[/FONT] <script src=”pictures.js” type=”text/javascript”></script> <p align=”center”> <script type=”text/javascript”> randomorder(picture, ‘<br><br>’) </script> </p>

With this code can I add a timer to make the pictures rotate on there own or do I have to write another whole code to make this work? Thanks!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @dropcake 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 5.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...