How to insert a row dynamically in a table which already exists in the page?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sasimca007
    New Member
    • Sep 2007
    • 129

    How to insert a row dynamically in a table which already exists in the page?

    Hello friends,
    What my doubt is, a page is already designed in that page a table exists, and i am doing a script like a radio button exixts and when click that radio button some function is called and in that function i want to create a extra row in that table which already exists on page. That is my problem.

    How to insert a row dynamically in a table which already exists in the page?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You can use the insertRow() method.

    PS. please use a good thread title. I've changed it to better describe the problem.

    Comment

    • sasimca007
      New Member
      • Sep 2007
      • 129

      #3
      How to insert a row dynamically in middle of table which already exists in the page?

      Thank you my friend i change how to put better title for questions.
      But can you help me with some sample code.

      Ok i got the sample code but it inserts a row on top of the table, but i want to add a row in middle of table i.e after some fields.
      Last edited by sasimca007; Nov 11 '08, 12:35 PM. Reason: To add something important

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Use the index to add the row at the specified position, e.g. insertRow(2) would add above the third row.

        Comment

        • sasimca007
          New Member
          • Sep 2007
          • 129

          #5
          Hai friend,
          Thanks for helping me but one another doubt if i want to modify a column of a row already existed in the table, how to do this? Is there any function like selectRow etc.....

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Once you have the row, use the the cells[] array to get the cells within a row and use the index to get the column you're after. To modify it, you can simply use its innerHTML property.

            Comment

            • sasimca007
              New Member
              • Sep 2007
              • 129

              #7
              Thank you my friend its working. Thank you.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                You're welcome. Glad to help :)

                Comment

                Working...