Results 1 to 4 of 4

Thread: Calling af function in JS with FOR

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question Calling af function in JS with FOR

    I have a number of functions names saet_dim1(), saet_dim2() ... saet_dim10(). How can I cal this function depending on a FOR?
    I have tried this:
    Code:
    for (j=1;j<11;j++){
       saet_dim' +j '();
    }
    but with no luck

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    cant you create one function and pass a parameter to it?

    Code:
    for (j=1;j<11;j++){
       saet_dim(j);
    }
    Then in the function update Dim1? Unless this is not what you're trying to achieve...
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049
    Hi Punkie
    Of course you're right, that would be the best solution, but the functions I need, are not build up like that, and they are very complicated to change. So I need to do it the other way, somehow like you showed me some time ago for elements:
    Code:
    document.test.elements('test'+i).value=5;

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    try this
    Code:
      for(i=0;i<2;i++)
         eval('saet_dim'+i+'()');
    the eval function has some security and speed issues that
    you might want to check out first

Posting Permissions

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



Click Here to Expand Forum to Full Width