/    Sign up×
Community /Pin to ProfileBookmark

Image changes at each load inside a table??

Hello!

For the following page [url]www.estudiode.es[/url] I have to change the background image of the main table each time I load the page (index)..I don’t know very much js but I’ve found the following script that do the image swapt each time it loads but not in the table background, just in the page background.
Please can you tell me what I have to change in the script for doing the image change inside <table> </table>?

Thank you very much,

Cristina

<SCRIPT language=”JavaScript”>

<!– Begin JS Script –>

<!– Begin
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages[0] = ‘http://www.estudiode.es/imagenes/imgcambio/img1.jpg
theImages[1] = ‘http://www.estudiode.es/imagenes/imgcambio/img2.jpg
theImages[2] = ‘http://www.estudiode.es/imagenes/imgcambio/img3.jpg
theImages[3] = ‘http://www.estudiode.es/imagenes/imgcambio/img4.jpg
theImages[4] = ‘http://www.estudiode.es/imagenes/imgcambio/img5.jpg

// do not edit anything below this line

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write(‘<img src=”‘+theImages[whichImage]+'”>’);
}

// End –>
</script>

<SCRIPT language=”JavaScript”>
<!– Begin
showImage();
// End –>
</script>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @crissy 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 4.20,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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