Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22661

Duplicating the last row of a Table

From Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid>
Newsgroups comp.lang.javascript
Subject Duplicating the last row of a Table
Date 2014-01-17 21:44 +0000
Organization Home
Message-ID <ZemAs3VzQa2SFwhs@invalid.uk.co.demon.merlyn.invalid> (permalink)

Show all headers | View raw


I wish to duplicate the last row of a Table, which contains cells like
<td>text</td> and <td><input type=text ...></td>, with a view to then
replacing the input elements with test representing their values (which
seems easy).


In HTML, I have something like

        <table>         <!-- abbreviated -->
        <tbody ID=TB>
        <tr><td><input type=text ...></td><td>AA</td></tr>
        <tr><td><input type=text ...></td><td>BB</td></tr>
        </tbody>
        </table>
        <input type=button onclick="Klone()">

and JavaScript

        var Rose = document.getElementById("TB").rows

        function Klone() {
          var node = Rose.item(Rose.length-1)
          var newnode = node.cloneNode(true);
          Rose.appendChild(newnode);
          }

which, in Firefox, produces
"TypeError: Rose.appendChild is not a function".

        It may help some if I remark that this line works :-
                Cel = Rose.item(Y).cells.item(X)

What should the code be, to work in current Firefox and other common
browsers?

        And, if anyone knows the cost, power consumption, life, and
        lumens output of a type of readily-available LED lamp that plugs
        directly into the sort of socket that commonly dangles from
        local domestic ceilings, that can be entered in the Table.
        Lumens should be in or near the range 500 to 1000.

-- 
 (c) John Stockton, nr London, UK.  For Mail, see Home Page.  Turnpike, WinXP.
 Web  <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
 Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
 DOS/Win/UNIX now 2.0.6;  see my <http://www.merlyn.demon.co.uk/pc-links.htm>.

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Duplicating the last row of a Table Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-01-17 21:44 +0000
  Re: Duplicating the last row of a Table Zlatko Duric <zladuric@gmail.com> - 2014-01-18 01:52 +0100
    Re: Duplicating the last row of a Table Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-18 12:53 +0100
      Re: Duplicating the last row of a Table RobG <rgqld@iinet.net.au> - 2014-01-19 17:00 +1000
        Re: Duplicating the last row of a Table Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-19 14:41 +0100
  Re: Duplicating the last row of a Table "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-18 12:16 +0100
    Re: Duplicating the last row of a Table Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-01-19 17:00 +0000
  Re: Duplicating the last row of a Table Danny <dann90038@gmail.com> - 2014-01-18 11:32 -0800

csiph-web