|
-
Apr 9th, 2004, 05:05 AM
#1
Thread Starter
Retired VBF Adm1nistrator
.options.remove() only removes some items ?
I have a dropdown, and I want to clear it, but this code only clears some items 
Code:
var i = 0; var dropDown = document.search.elements['selProductGroup'];
for (i = 0; i <= dropDown.length; i++) {
dropDown.options.remove(i);
}
-
Apr 9th, 2004, 05:11 AM
#2
Thread Starter
Retired VBF Adm1nistrator
And this doesn't make any difference...
Code:
for (i = 0; i <= dropDown.length; i++) {
if (! ( dropDown.options[i] == null ) )
dropDown.options.remove(dropDown.options[i].value);
}
-
Apr 9th, 2004, 07:32 AM
#3
Frenzied Member
Re: .options.remove() only removes some items ?
Code:
var i = 0; var dropDown = document.search.elements['selProductGroup'];
dropDown.options.length = 0;
Should clear it?
-
Apr 9th, 2004, 09:31 AM
#4
Frenzied Member
I don't think you can set the length equal to zero, length is read only I think.
also
if (! ( dropDown.options[i] == null ) )
should maybe be:
if (dropDown.options[i] != null )
or maybe that doesn't matter.
if this is a dropdown as in a <select>
then why not:
Code:
document.getElementById('selProductGroup').innerHTML = ""
that's if the select is:
<select id="selProductGroup" ... (whatever else)>
Have I helped you? Please Rate my posts. 
-
Apr 9th, 2004, 09:47 AM
#5
Frenzied Member
Works for me (Internet Explorer and FireFox)
Note: Rename to htm/html, apparently we can't upload html files.
Last edited by TomGibbons; Apr 9th, 2004 at 09:54 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|