#1
  1. a lazy guy
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    Hong Kong
    Posts
    99
    Rep Power
    13

    javascript: Assign cell property


    In IE

    I have a html table, eg

    <TABLE ID="VIEWTABLE" border="1"></TABLE>

    in my javascript:

    var x = VIEWTABLE.insertRow(0);
    var c1 = x.insertCell(0);
    var c2 = x.insertCell(1);
    c1.innerHTML = "hello_1";
    c2.innerHTML = "hello_2";

    // now i insert another row to the table,
    // and i'd like to make it colspan="2", but how?

    var y = VIEWTABLE.insertRow(1);
    var c3 = y.insertCell(0);
    y.cells[0].style.colspan = "2"; // this one seem not working
    c3.innerHTML = "hello_3";



    anyone got a solution here?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Location
    Argentina
    Posts
    11
    Rep Power
    0
    Try this:

    Code:
    object.colSpan [ = iCount ]
    iCount Integer that specifies or receives the number of columns to span. 
    This property can be changed only after the page has been loaded. 
    ---or----
    object.setAttribute(sName, vValue [, iFlags])
    sName Required. String that specifies the name of the attribute. 
    vValue Required. Variant that specifies the string, number, or Boolean to assign to the attribute.  
    iFlags Optional. Integer that specifies one the following flags: 
    0 When the attribute is set, it overwrites any attributes with the same name, regardless of their case. 
    1 Default. The case of the attribute that you set is respected when it is set on the object. 
    ---or----
    object.setExpression("colspan","2");

IMN logo majestic logo threadwatch logo seochat tools logo