conspiersacy
08-06-2006, 03:11 PM
i am designing a function that will generate a menu to be used across several websites. the code i have developed goes through all of the motion i want it to, except for one quirk: while in the loop, instead of going through the loop and inserting choice1, choice2, et cetera i want it to insert, in this example, news, profile, et cetera.
this is the call to the function:
<tr><td colspan="3" class="floatleft"><script type="text/javascript">menu(6,'news','profile','gallery','commission','links','contact','','','','');</script></td></tr>
this is the function itself:
function menu(choices, choice1, choice2, choice3, choice4, choice5, choice6, choice7, choice8, choice9, choice10)
{
document.write('<img src="menuspace_0.png" alt=""/>')
counter = 1;
while(counter <= choices)
{
document.write('<img class="link" src="menu_'+['choice'+counter]+'.png" alt="" onmouseover="this.src=\'menu_'+['choice'+counter]+'_h.png\';" onmouseout="this.src=\'menu_'+['choice'+counter]+'.png\';" onclick="changecontent(\''+['choice'+counter]+'\');"/>')
document.write('<img src="menuspace_'+counter+'.png" alt=""/>');
counter = counter + 1;
}
}
thanks in advance -- this is my first post. i hope i made myself clear. =)
this is the call to the function:
<tr><td colspan="3" class="floatleft"><script type="text/javascript">menu(6,'news','profile','gallery','commission','links','contact','','','','');</script></td></tr>
this is the function itself:
function menu(choices, choice1, choice2, choice3, choice4, choice5, choice6, choice7, choice8, choice9, choice10)
{
document.write('<img src="menuspace_0.png" alt=""/>')
counter = 1;
while(counter <= choices)
{
document.write('<img class="link" src="menu_'+['choice'+counter]+'.png" alt="" onmouseover="this.src=\'menu_'+['choice'+counter]+'_h.png\';" onmouseout="this.src=\'menu_'+['choice'+counter]+'.png\';" onclick="changecontent(\''+['choice'+counter]+'\');"/>')
document.write('<img src="menuspace_'+counter+'.png" alt=""/>');
counter = counter + 1;
}
}
thanks in advance -- this is my first post. i hope i made myself clear. =)