Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this a bug of IE regarding select?

 
Sophie Cameron
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

In a multi select, if you pick an item and scroll down so that the item is not visible, deleting the selected item will result in a blank entry in the select.

Here is an example.

<script type="text/javascript">

function remove() {
theSelect = document.myForm.mySelect;

while (theSelect.selectedIndex > -1) {
theSelect.remove(theSelect.selectedIndex);
}
}

</script>

<form name="myForm">

<select name="mySelect" size="3" multiple="yes">
<option value="1"/>1
<option value="2"/>2
<option value="3"/>3
<option value="4"/>4
<option value="5"/>5 longer one
</select>

<input type="button" value="Remove" onclicc="remove()"/>

</form>

Is this a bug of IE or there is a getaround?

Thanks,
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about after you remove all of the options?

That is what IE does, add a blank select like that and you can select the first blank.

Eric
 
Sophie Cameron
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I'm not talking about removing all of the options. I'm talking about removing ONLY ONE option.

Choose one option, scroll down so that it is not visible, and remove it. You'll see a blank option there.

That's not what is expected. The options array should have been compressed but actually not.

In the sample code, there are five options. After removing ONLY FIRST option following the steps, there are still five options there. The difference is that the first one is blank.

Thanks,
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of IE is this in? I am using IE6 and I have no problems

Eric
 
Sophie Cameron
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm also using IE6. To see the problem, you need to following the steps I provided. The point is that you have to scroll the select so that the selected option is NOT visible and then remove it by clicking the button.

It seems that the document needs reloading. I tried that but didn't help.

Thanks,
 
Carl Pettersson
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works fine for me too, but why do you have while(...) { remove() } ? Wouldn't an if(){ } be better?
 
Sophie Cameron
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just ran the sample code again and the problem is still there. Remember to change the to .

Thanks,
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try doing this instead:


Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see the issue, the line of coe above does not fix it. Don;t think there is anything you can do other than re-adding all the values (eewww)

Eric
 
Sophie Cameron
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

I'm happy you saw the issue.

Can you clarify your last response? I just didn't get your point.

Thanks,
 
Jason Liao
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody have answers for this post? I repeated in IE6(sp2)( use onclick instead!!) but it works fine in FireFox.

I am afraid it's a bug of IE 6.0.

Thanks for reply.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could bring the value into view (select the item again) and then remove it. Simple if it was not a multiple select.

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AH, here


Eric
 
Jason Liao
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Eric,

Thanks for your quick response, but the blank option is still there.

here are the steps to repeat
(1) select "2"
(2) scroll down untill you can not see it
(3) click "remove" button
(4) There is a black option between "1" and "3"

if you click the blank area, you get "3".(Duplcate "3"!).

It's Ok in feature but the blank is ugly. ( it does not appear in FireFox).

Anyway, thanks a lot for your effort.


Jason
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic