SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Wrong variable invoking

    Code:
    function agregar_row(){
                for (i=0; i<10; i++){
                    row="row/" . i;
                    if (document.getElementById(row).style.display=='none'){
                        document.getElementById(row).style.display='';
                        i=11;
                    }
                }
    }
    This function is intended to make visible a row, just one by each time the function is called.

    the way im invoking "(row)" is wrong, i think...

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I assume you are a PHP developer? use the + operator instead of .

    Also, why do you have i = 11? This loop will only run once if the if statement evaluates to true.

  3. #3
    Non-Member
    Join Date
    Aug 2006
    Location
    Kansas City
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function agregar_row(){
    var row;
    for (var i=0; i<10; i++){
    row="row" + i;
    if (document.getElementById(row).style.display=='none'){
    document.getElementById(row).style.display=''";
    }
    }
    }


    dont for get the "var" for the row variable

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would also better to store the current node you check into a variable so you don't lookup the node twice...


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
  •