I am trying to create a contacts page and trying to populate the contacts image and name. I am able to display the array of names but not the array of pictures. Just the first picture is displayed.
I am also trying to align the contact and the image in one row. But the contact image is displayed first then the contact name is displayed.
Here goes the code:
<script language="javascript" type="text/javascript">
function showContacts()
{
var myContacts=["abc","def","xyz"]; // literal array
for (var i=0;i<myContacts.length;i++)
{
document.getElementById('contact').innerHTML += myContacts[i]+"<br>";
//document.write(myArray[i]);
}
}
function preloader()
{
var myPhoto=["some photos"]; // literal array
// create object
var img=document.getElementById('photo');
// start preloading
for(var i=0; i< myPhoto.length; i++)
{
img.src += myPhoto[i]+"<br>";
//document.write(i);
//img.setAttribute('src',myPhoto[i]);
}
}
</SCRIPT>
<body onload="showContacts();preloader();">
<table width="100%" style="height: 100%;" border="0"><tr>
<col colspan="1" ><image id="photo"/>
<col colspan="1" ><p id="contact"/>
</tr></table>
</body>
</html>
What am I missing?