/    Sign up×
Community /Pin to ProfileBookmark

Urgent Help! Please ASAP

Hi! I am making my bands website, n i though this template would make my vision easy to do..but it hasn’t worked out how i’d of liked it to.

[url]www.penitentiary.co.uk[/url]

I have already put the other half of the script in, but it is this part which is wrong. It is script so that every time the home page is visited, 1 of 6 images appears at random adding variety…however, 4 of the images link to different areas of the site (this is possible?)

Below is the script..if you could help me based on what I offer you, or even correct it for me, i’d be so appriciative..as i’m pulling my hair out over this.

~Blade376

<script language=”JavaScript” type=”text/javascript”>
// This script was supplied free by Hypergurl
// [url]http://www.hypergurl.com[/url]
<!–
// JavaScript to interpolate random images into a page.
var ic = 6; // Number of alternative images
var xoxo = new Array(ic); // Array to hold filenames

xoxo[0] = “http://www.penitentiary.co.uk/Home%20Page%20Adverts/13th%20March%20Gig%20Edit.jpg“;
xoxo[1] = “http://www.penitentiary.co.uk/Home%20Page%20Adverts/EPADlarge.jpg“;
xoxo[2] = <p align=”center”><a href=”http://www.penitentiary.co.uk/EPcoverdesigns.htm”><img src=”http://www.penitentiary.co.uk/Home%20Page%20Adverts/epcoverdesignAD.jpg”></a>;
xoxo[3] = <p align=”center”><a href=”http://www.penitentiary.co.uk/Flyers.htm”><img src=”http://www.penitentiary.co.uk/Home%20Page%20Adverts/FlyersADlarge.jpg”></a>;
xoxo[4] = <p align=”center”><a href=”http://www.penitentiary.co.uk/forum/index.php”><img src=”http://www.penitentiary.co.uk/Home%20Page%20Adverts/ForumADlarge.jpg”></a>;
xoxo[5] = <p align=”center”><a href=”http://www.penitentiary.co.uk/news.htm”><img src=”http://www.penitentiary.co.uk/Home%20Page%20Adverts/MailinglistADlarge.jpg”></a>;

function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
}
}
// Write out an IMG tag, using a randomly-chosen image name.
var choice = pickRandom(ic);
// –>
</script>

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@Bad_ProgrammerSep 21.2004 — This is something similar to what I am trying to do, Blade. So far, I am still unsuccessful.

I was wondering if you ever found a solution. If you did, I would love to see it.
Copy linkTweet thisAlerts:
@Paul_JrSep 21.2004 — Here, try this.
[size=1]
&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
var pics = [
['linkurl', 'imgurl'],
['linkurl', 'imgurl'],
['linkurle', 'imgurl'],
'imgurl',
'imgurl'
];
function randImg(arr_len) {
var str = '';
var rand_num = Math.round(Math.random() * (pics.len - 1));
if(typeof pics[rand_num] == 'object') {
str += '&lt;a href="' + pics[rand_num][0] + '"&gt;&lt;img src="' + pics[rand_num][1] + '"&gt;&lt;/a&gt;';
}
else {
str += '&lt;img src="' + pics[rand_num] + '"&gt;';
}
return str;
}
//]]&gt;
&lt;/script&gt;[/size]

Place the following line where you want the random image to load:
<i>
</i>&lt;script type="text/javascript"&gt;document.write(randImg());&lt;/script&gt;

The script can be modified so you don't need that line; just an empty element to act as a container.
×

Success!

Help @Blade376 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.19,
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,
)...