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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

objects with array names

Status
Not open for further replies.

markwaldin

Technical User
Jan 25, 2002
6
US
I created a set of image objects using an array. I try to reference the image object's source image by using the array name and it doesn't work in IE.

For example:

test=new Array("sample1","sample2")
<img src=url name=test[0]>
.
.
.
document.test[0].src=&quot;newpicture.gif&quot;

This statement results in an object not defined.

If on the other hand the statement is entered:

document.sample1.src=&quot;newpicture.gif&quot; works fine.

How can I embed array variables in these property statements and make them work. All the books I have referenced have no examples using arrays.

 
I am not sure how your array ties up with the image issue.
Could you be a ittle more descriptive? May be post a link? --------------------------------------------------
Goals are dreams with deadlines
 
sorry to be vague. Don't have a link to reference but let me be more explicit here:

/*
this script creates a navigational bar with &quot;no_of_tabs&quot; tabs on it. If a user clicks on a tab, all other tabs turn tabblue.gif and the active tab goes tabwhite.gif
*/

<script language=&quot;javascript&quot;>

topnav_builder(10,0)

//initialize the top nav bar

function topnav_builder(no_of_tabs,activetab) {

document.write(&quot;<img src=\&quot;logo.gif\&quot; >&quot;)
tab_title=new Array()
tab_title[0]=&quot;Individual&quot;
tab_title[1]=&quot;Retailers&quot;
tab_title[2]=&quot;Pro Photographers&quot;
tab= new Array (&quot;tab0&quot;,&quot;tab1&quot;,&quot;tab2&quot;,&quot;tab3&quot;,&quot;tab4&quot;,&quot;tab5&quot;,&quot;tab6&quot;,&quot;tab7&quot;,&quot;tab8&quot;,&quot;tab9&quot;)

for (i=0;i<no_of_tabs;++i) {

if(i==activetab) {
document.writeln(&quot;<DIV STYLE= \&quot;left:&quot;+(200+200*i)+&quot;px;top:50px;\&quot;>&quot; )
//in the next line the image tab is created
document.writeln(&quot;<img src=\&quot;tabwhite.gif \&quot; name=\&quot;&quot;+tab+&quot;\&quot; >&quot;)
document.writeln(&quot;</DIV>&quot;)
document.writeln(&quot;<DIV STYLE= \&quot;left:&quot;+(200+200*i)+&quot;; top:53px;\&quot;>&quot; )
document.writeln(&quot;<a href=\&quot;javascript:tabcontroller(&quot;+i+&quot;,&quot;+activetab+&quot;)\&quot;>&quot;+tab_title+&quot;</a>&quot;)
document.writeln(&quot;</DIV>&quot;)

} else {
document.writeln(&quot;<DIV STYLE= \&quot;left:&quot;+(200+200*i)+&quot;px; top:50px\&quot;>&quot; )
document.writeln(&quot;<img src=\&quot;tabblue.gif\&quot; name=\&quot;&quot;+tab+&quot;\&quot; >&quot;)
document.writeln(&quot;</DIV>&quot;)
document.writeln(&quot;<DIV STYLE= \&quot;left:&quot;+(200+200*i)+&quot;; top:53px;\&quot;>&quot; )
document.writeln(&quot;<a href=\&quot;javascript:tabcontroller(&quot;+i+&quot;,&quot;+activetab+&quot;)\&quot;>&quot;+tab_title+&quot;</a>&quot;)
document.writeln(&quot;</DIV>&quot;)
}
}
}

function tabcontroller(tabselect,no_of_tabs) {
//here the active_tab which is white is turned blue (but it doesn't work)
document.tab[active_tab].src=tabblue.jpg'
//then the selected tab is turned white
document.tab[tabselect].src='sidetab_white.jpg'
//then the selected tab is made &quot;active&quot;
active_tab=tabselect
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top