I have a "select" in my template that has options hard-coded in the DCT. When the form loads my options are there, but the first one is blank and that's great because they have not made a selection. This select is used to name the DCR, so there is an onItemChange handler on this item that checks if the DCR corresponding to the selection exists and asks the user if they want to overwrite it. If they say no I would like to re-select the blank option, but by that time it is gone. If I remove my onItemChange handler I see that the empty item is still in the list after they make a selection. If I add an option label="" value="" to the DCT then I get two blanks when the form first loads.
What's going on here? Is the blank removed from the drop-down when the form redraws if an option is selected or something? Other than explicitly resetting all options in the drop-down and adding the blank on this condition, is there any way to get the blank back in without having two blanks sometimes?
Another weird thing - if in my onItemChange handler I remove the selected option from the drop-down, the blank is in the drop-down afterwards even though I didn't add it (meaning it's not really there), but getOptions.length is one higher than the number of options I have set (meaning it is really there):
if ( doesDCRexist( dcr ))
{
result = confirm( 'The DCR ' + dcr + ' already exists - any data you enter would overwrite the existing DCR. Do you want to continue and overwrite (OK) or select a different table (Cancel)?' );
if ( ! result )
{
var options = item.getOptions();
var newOpts = new Array();
var i = 0
for( var j = 0 ; j < options.length ; j++ )
{
if ( options.value != '' && ! item.getOptions().selected )
{
newOpts[i++] = options;
}
}
if ( options.length < 2 )
{
closeDCT( 'There are no records of this type to create.' );
}
else
{
item.setOptions( newOpts );
sortOptionsByLabels( item );
item.setFocus();
}
}
}
Edited by JimmyFat on 05/28/04 08:59 AM (server time).