Hi. i am a beginner a javascript. i have a code that can have random images show up in 2 separate spots on a page. i want to change it to have random images load on 4 separate spots on a page, but i don’t know how. here is the code:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “
<html xmlns=”
<head>
<meta http-equiv=”content-type” content=”text/html;charset=utf-8″ />
<meta name=”generator” content=”Adobe GoLive” />
<title>Test Page</title>
<link href=”../css/basic.css” rel=”stylesheet” type=”text/css” media=”all” />
<script language=”JavaScript”>
var theImages = new Array()
theImages[0] = ‘photo_00.jpg’
theImages[1] = ‘photo_01.jpg’
theImages[2] = ‘photo_02.jpg’
theImages[3] = ‘photo_03.jpg’
theImages[4] = ‘photo_04.jpg’
var otherImages = new Array()
otherImages[0] = ‘photo_05.jpg’
otherImages[1] = ‘photo_06.jpg’
otherImages[2] = ‘photo_07.jpg’
otherImages[3] = ‘photo_08.jpg’
otherImages[4] = ‘photo_09.jpg’
var j = 0
var p = theImages.length;
var preBuffer = new Array()
var preBuffer2 = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
preBuffer2[i] = new Image()
preBuffer2[i].src = otherImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
var otherImage = Math.round(Math.random()
function showImage(){
document.write(‘<img src=”‘+theImages[whichImage]+'”>’);
}
function showImage2(){
document.write(‘<img src=”‘+otherImages[otherImage]+'”>’);
}
</script>
</head>
<body leftmargin=”0″ marginheight=”0″ marginwidth=”0″ topmargin=”0″>
<table width=”800″ border=”0″ cellspacing=”0″ cellpadding=”0″ height=”180″>
<tr height=”180″>
<td width=”200″ height=”180″>
<script language=”JavaScript”>
showImage();
</script>
</td>
<td width=”200″ height=”180″>
<script language=”JavaScript”>
showImage2();
</script>
</td>
<td width=”200″ height=”180″>
<script language=”JavaScript”>
showImage3();
</script>
</td>
<td width=”200″ height=”180″>
<script language=”JavaScript”>
showImage4();
</script>
</td>
</tr>
</table>
</body>
</html>