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!

can't get array variables to process right with object descriptor

Status
Not open for further replies.

markwaldin

Technical User
Jan 25, 2002
6
US
If I try an address a object property using a variable it does not work. For example having document.myimage.src having myimage as an image objects name is identified correctly. Substituting a variable for myimage such as newimage=myimage; document.newimage.src is not recognized as a defined object. Below is a piece of sample code showing what I am trying to do that doesn't work:

/*
this script creates a navigational bar with "no_of_tabs" 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. If I change tab[active_tab] to it's value then it works...??
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