Re: Clear all optgroups and options from a select list
- From: "darwinist" <darwinist@xxxxxxxxx>
- Date: 6 Aug 2006 00:29:45 -0700
RobG wrote:
darwinist wrote:
Brian D wrote:
I have a multiple select list that is created dynamically based on a
previous selection on an asp page. The first thing I do is to clear
the curent option list by
document.form1.itemcross.length = 0;
The only problem is that it leaves the optgroups. How do I also get
rid of the optgroups?
Thanks
BrianD
You need an id for the object or a reference to it:
The OP has already indicated how he's doing that, and may be using
either an ID or a NAME attribute.
<script>
Please don't recommend using invalid HTML. Do it in your own library
if you wish, but don't encourage it here.
// delete an object by reference
function del(element){element.parentNode.removeChild(element);}
The OP is attempting to remove the child nodes, not the element itself.
Isn't an optgroup an element that you can remove like any other?
http://www.w3schools.com/tags/tag_optgroup.asp
--
Rob
.
- Follow-Ups:
- References:
- Clear all optgroups and options from a select list
- From: Brian D
- Re: Clear all optgroups and options from a select list
- From: darwinist
- Re: Clear all optgroups and options from a select list
- From: RobG
- Clear all optgroups and options from a select list
- Prev by Date: Re: Modifying A tag onclick events dynamically - am I crazy
- Next by Date: Re: Modifying A tag onclick events dynamically - am I crazy
- Previous by thread: Re: Clear all optgroups and options from a select list
- Next by thread: Re: Clear all optgroups and options from a select list
- Index(es):
Relevant Pages
|