How to change the content in the table cell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gpcgeek
    New Member
    • Feb 2010
    • 3

    How to change the content in the table cell

    I've a situation where upon selecting a month in a drop down the value in the <td> cell should change. It is a table oriented UI where it shows values
    _______________ ______________
    | Lable: | Value1 | Value2 | Value3 |
    ---------------------------------------------------
    Value1, value2 value3 are different values and once I select a different month only the values should change not the lable. Like Value1 changes to Value4, Value2 changes to Value5, and Value3 changes to Value6.

    This should happen once they select a value from the drop down dynamically. I've the UI developed in html and validations in asp.net and backend in vb. Can anyone please help regarding this.

    Let me know if you have any more questions.
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    You can achieve that easily. But in that table whether there will be only one row or more rows ? If there going to be only one rows means you can use the following code.

    Code:
    var tblObj = document.getElementById('yourTableId');
    tblObj.rows[0].cells[1].innerHTML='value1';
    tblObj.rows[0].cells[2].innerHTML='value2';
    tblObj.rows[0].cells[3].innerHTML='value3';
    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • gpcgeek
      New Member
      • Feb 2010
      • 3

      #3
      Originally posted by RamananKaliraja n
      You can achieve that easily. But in that table whether there will be only one row or more rows ? If there going to be only one rows means you can use the following code.

      Code:
      var tblObj = document.getElementById('yourTableId');
      tblObj.rows[0].cells[1].innerHTML='value1';
      tblObj.rows[0].cells[2].innerHTML='value2';
      tblObj.rows[0].cells[3].innerHTML='value3';
      Thanks and Regards
      Ramanan Kalirajan
      Thanks Ramanan for the reply, but the UI has more than 10 rows. Can I do that using ID=" " stuff?

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        yes u can do it with the Id. But can you please elaborate your requirement.

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        • gpcgeek
          New Member
          • Feb 2010
          • 3

          #5
          Originally posted by RamananKaliraja n
          yes u can do it with the Id. But can you please elaborate your requirement.

          Thanks and Regards
          Ramanan Kalirajan
          I'm for replying late Mr.Ramanan Kalirajan, Its like I've a 15 rows and 4 columns of table, for the page design and upon the selection of the drop down on top of the page, the data in the 10th row and the Column=1,2,3 (and not 'Column=0') should change its content. Like previously it has content of
          _______________ _______
          | Lable: | 4 | 5 | 6 |
          -----------------------------------
          for the selection of Month:may Year:2010 and if user selects month and year which is higher than may 2009, it should change those static values to
          _______________ ______
          | Lable: | 4.5 | 5.65 | 6.76 |
          -----------------------------------
          Can we do it using an 'Id'-tag, because the behavior is written somewhere on TOP and the UI is written in the Table tag below.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            note: in IE, .innerHTML is read-only for tables.

            Comment

            • RamananKalirajan
              Contributor
              • Mar 2008
              • 608

              #7
              Yes u can do that... for 'tr' 1 u can give the id of the td's as 'tr1td0' for first td like wise u can have and access the td content and easily change its value

              Thanks and Regards
              Ramanan Kalirajan

              Comment

              Working...