How to remove items of a select field

S

sniper

Hi all;
i'm adding items to a select list like this:

var insertPoint = inst.getElementsByTagName("itemlist").item(0);
var itemCount = insertPoint.getElementsByTagName("item").length;
for(x=0;x<found.length;x++)
{
alert(found[x])
var item = document.createElementNS("", "item")
item.appendChild(document.createTextNode(found[x]))
insertPoint.appendChild(item)
}

Now if i want to delete all items of this select list how to do it?
thanks for your help
 
P

Paul

sniper said:
Hi all;
i'm adding items to a select list like this:

var insertPoint = inst.getElementsByTagName("itemlist").item(0);
var itemCount = insertPoint.getElementsByTagName("item").length;
for(x=0;x<found.length;x++)
{
alert(found[x])
var item = document.createElementNS("", "item")
item.appendChild(document.createTextNode(found[x]))
insertPoint.appendChild(item)
}

Now if i want to delete all items of this select list how to do it?
thanks for your help

The code to work with here is a bit sparce but, I'll have a go at it
anyway. (BTW, is this xforms?)
var insertPoint = inst.getElementsByTagName("itemlist").item(0);
var items = insertPoint.getElementsByTagName("item");
for( i=0; i<items.length; i++)
{
insertPoint.removeChild(items);
}

ref: http://developer.mozilla.org/en/docs/DOM:element.removeChild
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top