D.D. de Kerf
July 2nd, 2001, 02:31 AM
Hi,
I'm writing a function that moves the selected options from one listbox to another. To do this, I first find the selected OPTION-elements, remove them from the SELECT-element (not from the document!) and then insert them in the other SELECT-element...
But the removeChild function doesn't want to remove the selected item.
// Get the selected option-tag (pFromNode is a SELECT-element, pOption is the n-th OPTION-element)
pOption = pFromNode.childNodes.item(i);
// pOption points to the right option. I know this, 'cause I've inspected the text of the element
// This next line, though, doesn't remove the n-th OPTION-element, but ALWAYS the last one.
pMoveOption = pFromNode.removeChild(pOption);
Any solutions???
> Structured programming vs. chaotic mind boggling
I'm writing a function that moves the selected options from one listbox to another. To do this, I first find the selected OPTION-elements, remove them from the SELECT-element (not from the document!) and then insert them in the other SELECT-element...
But the removeChild function doesn't want to remove the selected item.
// Get the selected option-tag (pFromNode is a SELECT-element, pOption is the n-th OPTION-element)
pOption = pFromNode.childNodes.item(i);
// pOption points to the right option. I know this, 'cause I've inspected the text of the element
// This next line, though, doesn't remove the n-th OPTION-element, but ALWAYS the last one.
pMoveOption = pFromNode.removeChild(pOption);
Any solutions???
> Structured programming vs. chaotic mind boggling