SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    passing parameters

    I'm trying to pass a parameter but am having problems.
    Can anyone tell me what I am doing wrong.
    If on the line
    permissions.onclick = createDialog(eval(i));
    I only do
    permissions.onclick = createDialog;,
    then take out mylist parameter, all works fine.

    If I leave it as is, the createDialog function gets executed right after the initDialog, instead of waiting.

    I even tried just using 1 instead of eval(i) but no go either.

    TIA
    Patricia

    Code:
    // JavaScript Document
    addLoadListener(initDialog);
    
    function initDialog()
    {
      for ( i = 1 ; i <= 25 ; i ++ )
      {
        var permissions = document.getElementById("permissions" + i);
        permissions.onclick = createDialog(eval(i));
      }
      return true;
    }
    
    function createDialog(mylist)
    {
      var body = document.getElementsByTagName("body")[0];
      var pageDimensions = getPageDimensions();
      var viewportSize = getViewportSize();
      var printlist = "name etc "  ;

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try

    permissions.onclick = new Function("createDialog(" + i + ")");

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that works great.

    Patricia


Bookmarks

Posting Permissions

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