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

Array in a loop

Status
Not open for further replies.

greyone

Programmer
Dec 14, 2000
200
CA
I would like to put the following code in some sort of a loop. Is this possible.
Please help.

var menutitles=new Array()
var menulinks=new Array()

menulinks[0]='hello(\'thestring\')'
menutitles[0]='Header'

menulinks[1]='window.location=\'test.html\';return false'
menutitles[1]=' > Account Exec.'

menulinks[2]='window.location=\'test.html\';return false'
menutitles[2]=' > Employee Reps.'

menulinks[3]='window.location=\'test.html\';return false'
menutitles[3]='Overview'

menulinks[4]='window.location=\'test.html\';return false'
menutitles[4]=' > Currency Relations'

menulinks[5]='window.location=\'test.html\';return false'
menutitles[5]='Business Profile'

menulinks[6]='window.location=\'test.html\';return false'
menutitles[6]=' > Abeyances'

menulinks[7]='window.location=\'test.html\';return false'
menutitles[7]=' > Reports of Discussion'

menulinks[8]='window.location=\'test.html\';return false'
menutitles[8]=' > Coverage'

menulinks[9]='window.location=\'test.html\';return false'
menutitles[9]='Industry'

menulinks[10]='window.location=\'test.html\';return false'
menutitles[10]='Division'

menulinks[11]='window.location=\'test.html\';return false'
menutitles[11]='Address'

menulinks[12]='window.location=\'test.html\';return false'
menutitles[12]='Contacts'

menulinks[13]='window.location=\'test.html\';return false'
menutitles[13]='Service'

menulinks[14]='window.location=\'test.html\';return false'
menutitles[14]='Status Notes'
 
you could have it n a loop, but, from the looks of your code, it would be a lot more annoying to use then what you are doing. luciddream@subdimension.com
 
well is it possible for you to show me how to. The only problem i think is that i don't know how would i pass different values to the arrays. What i mean is how would i do something like this:
menulinks[11]='window.location=\'test.html\';return false'
menutitles[11]='Address'

where test.html is a link or it could be some javascript function and Address is the text which is displayed.

Please help

 
well, to use a loop:


var menulinks = new Array();
var menutitles = new Array();
for(var i = 0; i < 12; i++)
{
menulinks = ;
menutitles = ;
}

like i said... it doesn't make much sense for you to use a loop, but, that is how a loop works. luciddream@subdimension.com
 
Well if you say that it dose'nt make much sense to use a loop then what do you think should solve this problem. Is there some other way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top