How to pass an array as a parameter?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SM

    How to pass an array as a parameter?

    Hello,
    Such a simple question and i can't find the answer(see code below).
    Here it is:

    I have a function: ini()
    In that function, i call a function (load_CDThumbna il) that creates an
    array and returns the newly created array
    Then, another function is called (show) that needs to pass the newly
    created array as a parameter. That's the part that i don't know how to
    program
    How to pass an array as a parameter?


    Thanks
    Marco


    function ini()
    {
    var thumbnail = load_CDThumbnai l();
    show(thumbnail) ; ??????
    }


    function load_CDThumbnai l()
    {
    var cdThumbnail = new Array();

    ...

    return cdThumbnail;
    }


    function show(???thumbna il???)
    {
    ...
    for(var i=0; i<thumbnail.len gth; i++)
    {
    alert("testing" + i);
    }
    ...
    }

  • Lee

    #2
    Re: How to pass an array as a parameter?

    SM said:
    >
    >Hello,
    >Such a simple question and i can't find the answer(see code below).
    >Here it is:
    >
    >I have a function: ini()
    >In that function, i call a function (load_CDThumbna il) that creates an
    >array and returns the newly created array
    >Then, another function is called (show) that needs to pass the newly
    >created array as a parameter. That's the part that i don't know how to
    >program
    >How to pass an array as a parameter?
    >
    >
    >Thanks
    >Marco
    >
    >
    >function ini()
    >{
    var thumbnail = load_CDThumbnai l();
    show(thumbnail) ; ??????
    >}
    >
    >
    >function load_CDThumbnai l()
    >{
    var cdThumbnail = new Array();
    >
    ...
    >
    return cdThumbnail;
    >}
    >
    >
    >function show(???thumbna il???)
    >{
    ...
    for(var i=0; i<thumbnail.len gth; i++)
    {
    alert("testing" + i);
    }
    ...
    >}
    There's no trick to it:

    <html>
    <body>
    <script type="text/javascript">

    function ini()
    {
    var thumbnail = load_CDThumbnai l();
    show(thumbnail) ;
    }

    function load_CDThumbnai l()
    {
    var cdThumbnail = new Array();
    cdThumbnail.pus h("hello");
    cdThumbnail.pus h("world");
    return cdThumbnail;
    }

    function show(thumbnail)
    {
    for(var i=0;i<thumbnail .length;i++)
    {
    alert("testing: "+thumbnail[i])
    }
    }

    ini();

    </script>
    </body>
    </html>


    --

    Comment

    • SM

      #3
      Re: How to pass an array as a parameter?

      On May 25, 4:39 pm, Lee <REM0VElbspamt. ..@cox.netwrote :
      SM said:
      >
      >
      >
      >
      >
      Hello,
      Such a simple question and i can't find the answer(see code below).
      Here it is:
      >
      I have a function: ini()
      In that function, i call a function (load_CDThumbna il) that creates an
      array and returns the newly created array
      Then, another function is called (show) that needs to pass the newly
      created array as a parameter. That's the part that i don't know how to
      program
      How to pass an array as a parameter?
      >
      Thanks
      Marco
      >
      function ini()
      {
      var thumbnail = load_CDThumbnai l();
      show(thumbnail) ; ??????
      }
      >
      function load_CDThumbnai l()
      {
      var cdThumbnail = new Array();
      >
      ...
      >
      return cdThumbnail;
      }
      >
      function show(???thumbna il???)
      {
      ...
      for(var i=0; i<thumbnail.len gth; i++)
      {
      alert("testing" + i);
      }
      ...
      }
      >
      There's no trick to it:
      >
      <html>
      <body>
      <script type="text/javascript">
      >
      function ini()
      {
      var thumbnail = load_CDThumbnai l();
      show(thumbnail) ;
      }
      >
      function load_CDThumbnai l()
      {
      var cdThumbnail = new Array();
      cdThumbnail.pus h("hello");
      cdThumbnail.pus h("world");
      return cdThumbnail;
      }
      >
      function show(thumbnail)
      {
      for(var i=0;i<thumbnail .length;i++)
      {
      alert("testing: "+thumbnail[i])
      }
      }
      >
      ini();
      >
      </script>
      </body>
      </html>
      >
      --
      JEs!!!!!!
      Its time for me to rest..

      Thanks lee

      Comment

      Working...