How to display a list box in a table cell after selection?

Discussion in 'Javascript' started by tomix, Oct 23, 2006.

  1. tomix

    tomix Guest

    I am writing an editable grid control and i need
    to move a list box from one cell to the other
    after the user select to edit the cell,the list box will display
    available options for the column


    how can i do it with java script? i mean what is the best way to move
    an item between cells?

    Thanks in advance
     
    tomix, Oct 23, 2006
    #1
    1. Advertising

  2. tomix wrote:

    > i mean what is the best way to move
    > an item between cells?


    You can move any node to a new parent by simply doing e.g.
    newParent.appendChild(node)
    e.g.
    someCell.appendChild(selectElement)
    as calling appendChild with an argument that is already inserted
    somewhere in the DOM tree first removes it from its old parent and then
    inserts it as a child of the new parent. The same holds for other
    methods like insertBefore.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Oct 23, 2006
    #2
    1. Advertising

  3. tomix

    ASM Guest

    tomix a écrit :
    > I am writing an editable grid control and i need
    > to move a list box from one cell to the other
    > after the user select to edit the cell,the list box will display
    > available options for the column
    >
    > how can i do it with java script? i mean what is the best way to move
    > an item between cells?


    <script type="text/javascript">

    function move() {
    // the select to move
    var original = document.getElementById('mySelect');
    // the table
    var table = document.getElementById('myTable');
    // cell where to move to
    var target = table.rows[3].cells[3];
    // fire
    target.appendChild(original);
    }

    </script>
     
    ASM, Oct 23, 2006
    #3
  4. tomix

    tomix Guest

    Martin Honnen wrote:
    > tomix wrote:
    >
    > > i mean what is the best way to move
    > > an item between cells?

    >
    > You can move any node to a new parent by simply doing e.g.
    > newParent.appendChild(node)
    > e.g.
    > someCell.appendChild(selectElement)
    > as calling appendChild with an argument that is already inserted
    > somewhere in the DOM tree first removes it from its old parent and then
    > inserts it as a child of the new parent. The same holds for other
    > methods like insertBefore.
    >
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    tomix, Oct 23, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.rcn.com
    Replies:
    1
    Views:
    9,673
    Chris Smith
    Jul 12, 2004
  2. Simon Niederberger
    Replies:
    2
    Views:
    16,527
    Christian Kaufhold
    Jan 7, 2005
  3. Phillip Roncoroni
    Replies:
    14
    Views:
    1,098
    Toby A Inkster
    Apr 5, 2004
  4. JamesW
    Replies:
    0
    Views:
    557
    JamesW
    Sep 11, 2006
  5. Adrian
    Replies:
    1
    Views:
    222
    Bullschmidt
    Feb 18, 2004
Loading...

Share This Page