Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    calling arguments from one function to another

    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:

    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>
    Code:
    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=""/>')
    };
    Code:
    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 =)
    Last edited by conspiersacy; 09-02-2006 at 06:07 PM.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    use dynamic DOM methods (even innerHTML nonstandard) instead of document.write() to create elements/text on a certain plave in a peg.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •