CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2003
    Location
    Belgium
    Posts
    21

    Array of cell of a table

    How can I make an array of cells of a table? And I want to change the properties with VbScript

  2. #2
    Join Date
    Feb 2003
    Location
    Oakland, CA
    Posts
    29
    It depends on what you're asking, but you should probably not do it in vbScript. Use javascript which is an implementation of the ECMA script specifications which means it is standards compliant (for the most part).

    If you're trying to create an array that represents an existing set of cells within a table, there's a couple ways to do it.

    The table.cells property works in internet explorer ie. It gives you a sequentially ordered array of all the cells in the table, so cells[3] is the fourth cell starting with the topmost left.

    Using standards compliant DOM methods, you can get the table object and then get each array of row's cells one at a time.

    So, table.childNodes[0] is the first row. table.childNodes[0].childNodes is the array of cells within the first row, and so on.


    If you want to create an array on the fly, you use the document.createElements("TD") method and put each cell you create into a regular old javascript array. For inserting the cells into a row, you get a handle on the row object that you want to put them into, and for each cell in the array, you shoudl call
    appendChild on the row, like so:


    cellsArray[0] = document.createElement("TD");
    // add stuff to the cell
    cellsArray[1] = document.createElement("TD");
    // add stuff to the cell
    cellsArray[2] = document.createElement("TD");
    // add stuff to the cell


    for(var i=0;i<cellsArray.length;i++){
    myRow.appendChild(cellsArray[i]);
    }
    Nate Grover
    http://www.nategrover.com

  3. #3
    Join Date
    Feb 2003
    Location
    Belgium
    Posts
    21
    I'm making a table and if you go over the cells with the mouse then they the color should change.

    I gave every cell a name and then for every cell I made a sub. But I want to make one sub for all the cells.

    How can I do this?
    Last edited by Geudens; March 20th, 2003 at 12:52 PM.

  4. #4
    Join Date
    Feb 2003
    Location
    Oakland, CA
    Posts
    29
    Create two style rules.

    TD.normal{
    background-color:white;
    }

    TD.hover{
    background-color:black;
    }


    then, add these two event handlers to each Table cell:

    onmouseover = 'this.className="hover";'
    onmouseout = 'this.className = "normal";'
    Nate Grover
    http://www.nategrover.com

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

Featured