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

T

tomix

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
 
M

Martin Honnen

tomix said:
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.
 
A

ASM

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>
 
T

tomix

Martin said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top