Bug when setting value on a select element and the select is empty
| Project: | Field Plug-in |
| Version: | 0.7 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | DanSwitzer2 |
| Status: | closed |
Jump to:
Hi,
This is an exeptional case, which does not happen in normal scenarios although it should be handled.
When you set Value on a select element which is empty I receive a js error.
line 313:
this[0].selected = true; // saying this[0] has no properties
as the whole select is empty this make sense.
so I suggest the following modification...
from:
if( bSelectOne && bKeepLooking ){
this[0].selected = true;
}
to:
if( bSelectOne && bKeepLooking ){
if ( this[0] ) this[0].selected = true;
}
I am not sure this is the best way to handle it.

Comments
#1
I tested this under IE6 and FF2 and wasn't able to recreate the problem. I'll put in a check for it though.
#2
Scrath that, I had a bug in my test code. I was able to recreate the problem and I've fixed the problem in v0.8 with:
// if a select-one box and nothing selected, then try to select the default value
if( bSelectOne && bKeepLooking && !!this[0] ){
this[0].selected = true;
}
#3
#4