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. Advertisements

  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. Advertisements

  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. Advertisements

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. Replies:
    1
    Views:
    1,357
    David Wier
    Aug 5, 2005
  2. news.rcn.com
    Replies:
    1
    Views:
    10,245
    Chris Smith
    Jul 12, 2004
  3. Simon Niederberger
    Replies:
    2
    Views:
    18,544
    Christian Kaufhold
    Jan 7, 2005
  4. Phillip Roncoroni
    Replies:
    14
    Views:
    1,378
    Toby A Inkster
    Apr 5, 2004
  5. JamesW
    Replies:
    0
    Views:
    657
    JamesW
    Sep 11, 2006
  6. curiousity

    HOWTO autopost the selection list upon selection

    curiousity, Nov 21, 2003, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    415
    curiousity
    Nov 21, 2003
  7. rikesh

    Display User Selection From Combo Box

    rikesh, Feb 6, 2004, in forum: ASP General
    Replies:
    8
    Views:
    308
    rikesh
    Feb 9, 2004
  8. Adrian
    Replies:
    1
    Views:
    477
    Bullschmidt
    Feb 18, 2004
Loading...