Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading random image into IMAGE PLACEHOLDER? 1

Status
Not open for further replies.

leTigre

Programmer
Mar 26, 2003
13
US
Hi, I'm using the following code to place a random image with links:

<script language=&quot;JavaScript&quot;>
function random_imglink(){
var myimages=new Array()

myimages[1]=&quot;/Homepage/images/mainFrame_Beth_01.gif&quot;
myimages[2]=&quot;/Homepage/images/mainFrame_Darla_01.gif&quot;
myimages[3]=&quot;/Homepage/images/mainFrame_Natalie_01.gif&quot;
myimages[4]=&quot;/Homepage/images/mainFrame_Toni_01.gif&quot;
myimages[5]=&quot;/Homepage/images/mainFrame_Twins_01.gif&quot;
myimages[6]=&quot;/Homepage/images/mainFrame2_01.gif&quot;
myimages[7]=&quot;/Homepage/images/mainFrame_Vivian_01.gif&quot;


var imagelinks=new Array()
imagelinks[1]=&quot;/MainFrame/mf_PS_Beth.htm&quot;
imagelinks[2]=&quot;/MainFrame/mf_PS_Darla.htm&quot;
imagelinks[3]=&quot;/MainFrame/mf_PS_natalie.htm&quot;
imagelinks[4]=&quot;/MainFrame/mf_PS_Toni.htm&quot;
imagelinks[5]=&quot;/MainFrame/mf_PS_twins.htm&quot;
imagelinks[6]=&quot;/MainFrame/mf_PS_laPorscha.htm&quot;
imagelinks[7]=&quot;/MainFrame/mf_PS_Vivian.htm&quot;

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'&quot;'+imagelinks[ry]+'&quot;'+'><img src=&quot;'+myimages[ry]+'&quot; border=0 ></a>')
}
random_imglink()
//-->
</script>


I would like the random image to appear in a specific spot in a table. I've created an image placeholder for it to go into (same size as the random images, named &quot;ps&quot;)--> how can I alter the script to tell it where to load into? As is, the random image loads above the table. THANKS!!
 
<script language=&quot;JavaScript&quot;>
function random_imglink(){
var myimages=new Array()

myimages[1]=&quot;/Homepage/images/mainFrame_Beth_01.gif&quot;
myimages[2]=&quot;/Homepage/images/mainFrame_Darla_01.gif&quot;
myimages[3]=&quot;/Homepage/images/mainFrame_Natalie_01.gif&quot;
myimages[4]=&quot;/Homepage/images/mainFrame_Toni_01.gif&quot;
myimages[5]=&quot;/Homepage/images/mainFrame_Twins_01.gif&quot;
myimages[6]=&quot;/Homepage/images/mainFrame2_01.gif&quot;
myimages[7]=&quot;/Homepage/images/mainFrame_Vivian_01.gif&quot;


var imagelinks=new Array()
imagelinks[1]=&quot;/MainFrame/mf_PS_Beth.htm&quot;
imagelinks[2]=&quot;/MainFrame/mf_PS_Darla.htm&quot;
imagelinks[3]=&quot;/MainFrame/mf_PS_natalie.htm&quot;
imagelinks[4]=&quot;/MainFrame/mf_PS_Toni.htm&quot;
imagelinks[5]=&quot;/MainFrame/mf_PS_twins.htm&quot;
imagelinks[6]=&quot;/MainFrame/mf_PS_laPorscha.htm&quot;
imagelinks[7]=&quot;/MainFrame/mf_PS_Vivian.htm&quot;

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'&quot;'+imagelinks[ry]+'&quot;'+'><img src=&quot;'+myimages[ry]+'&quot; border=0 ></a>')
}
//random_imglink() dont use it here
//-->
</script>


<body>
<table>
<tr>
<td>
Some descriptive text here
</td>
<td>
<script>
random_imglink();
</script>

</td>
</tr>
</table>
</body>

see if that works.

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
That worked perfectly! I knew the answer had to be simplier than I thought...sometimes it's hard to see the trees from the forrest, you know? Thanks a lot.[medal]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top