SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Table add rows in all browsers except Internet Explorer

    Hi,

    I have a function where it add rows into a table. For the example below it adds a row under the Question column, (I have not included whole function as there is a lot of code so instead I have just posted the relevant code.

    Code:
    //This is inside a function
    
    var row = document.createElement("tr");
    	var cell
            input,
            alertErrors = "",
            // Note, this is just so it's declared...
            qnum = 1;
    
     cell = document.createElement("td"),
            input = document.createElement("textarea");
        cell.className = "question";
        input.name = "question_" + qnum;
        input.value = form.questionText.value;
        cell.appendChild(input);
        row.appendChild(cell);
    Now my function works really well when it comes to adding a row into a table. The problem is that it works on all major browsers except for Internet Explorer. I have researched an found out that I may need to use insertRow() and insertCell() methods. I don't know how to really apply this into my code so what I want to know is that if somebody knows how to manipulate the code above to include the insertRows and insertCell methods, then can you please do this for the code above. It means I know how insertRow() and insertCell is added in the code and I can include this in all of my other columns in the function.

    Thank You

  2. #2
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by carlbrooks View Post
    ...... so what I want to know is that if somebody knows how to manipulate the code above to include the insertRows and insertCell methods, then can you please do this for the code above.......
    This w3schools tute gives a good description and example code for insertRow() (saves me a lot of typing)

    If you wrote the code you posted, the above tute should be straight forward for you.


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
  •