...

View Full Version : calling arguments from one function to another



conspiersacy
09-02-2006, 05:04 PM
i have a page which is built by javascript. i have one function which builds a menu into the design of the page, and another function which builds a list of text hyperlinks below the design to serve as an alternate menu. both functions are supplied with exactly the same arguments, however i do not want to combine them into one function because the html will be written inline and i want to avoid display problems.

i would, however, like the second function to draw the arguments from the first function so i have to supply the information only once. the only functions of concern are "menu" and "footer." here is my code:



<body class="main">

<table cellspacing="0" class="interface">
<tr><td colspan="3"><img src="skiphantom.png" alt=""/></td></tr>
<tr><td colspan="3" class="floatleft"><script type="text/javascript">menu('phantomskis','Phantom Skis','productinfo','Product Info','specifications','Specifications','purchase','Purchase','contactus','Contact Us');</script></td></tr>
<tr><td colspan="3"><img src="content_top.png" alt=""/></td></tr>
<tr>
<td><img src="content_left.png" alt=""/></td>
<td>
<table cellspacing="0">
<tr><td colspan="3" class="floatleft"><script type="text/javascript">title('phantomskis');</script></td></tr>
<tr>
<td class="content"><script type="text/javascript">iframe('phantomskis',510,240);</script></td>
<td><script type="text/javascript">scroll();</script></td>
<td><img src="photo_phantomskis.png" id="photo" name="photo" alt=""/></td>
</tr>
</table>
</td>
<td><img src="content_right.png" alt=""/></td>
</tr>
<tr><td colspan="3"><img src="content_bottom.png" alt=""/></td></tr>
</table>
<script type="text/javascript">footer('Ski Phantom',2004,'ACnrXA9m4wtVEIyvbdFyb2hjphAA');</script>

</body>




function menu()
{
var count = 0;
var space = 0;
while(menu.arguments[count] != undefined)
{
document.write('<img src="menuspace_'+space+'.png" alt=""/>');
document.write('<a href="javascript:changecontent(\''+menu.arguments[count]+'\');"><img class="link" src="menu_'+menu.arguments[count]+'.png" alt="'+menu.arguments[count+1]+'" onmouseover="this.src=\'menu_'+menu.arguments[count]+'_h.png\';" onmouseout="this.src=\'menu_'+menu.arguments[count]+'.png\';"/></a>');
count = count + 2;
space = space + 1;
}
document.write('<img src="menuspace_'+space+'.png" alt=""/>')
};



function footer(licensee,year,webstats4u)
{
var count = 0;
while(menu.arguments[count] != undefined)
{
document.write('| <a href="javascript:changecontent(\''+menu.arguments[count]+'\');">'+menu.arguments[count+1]+'</a> ');
count = count + 2;
}
document.write('|<br/><br/>');

var today = new Date();
if(year==today.getFullYear())
{
document.write('Copyright &copy; '+year+' '+licensee+'. All rights reserved. Reproduction without permission is a violation of applicable laws.<br/>');
}
else
{
document.write('Copyright &copy; '+year+'-'+today.getFullYear()+' '+licensee+'. All rights reserved. Reproduction without permission is a violation of applicable laws.<br/>');
}
document.write('Design by <a href="http://www.conspiersacy.com/" target="_blank">Greg Spiers</a>. Best viewed with a display resolution of 1024 X 768 and 24-bit color depth.<br/>');
if(webstats4u!='')
{
document.write('<img class="link" style="position:absolute;top:0px;left:0px;" src="http://m1.webstats4u.com/n?id='+webstats4u+'" alt=""/>');
}
};


thanks =)

Kor
09-02-2006, 06:42 PM
use dynamic DOM methods (even innerHTML nonstandard) instead of document.write() to create elements/text on a certain plave in a peg.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum