We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I have a drop list but once I have selected a value it doesn't display in the drop list box. I get the value like this:
intListIndex = lboxLine.getSelectedIndex()-1;
Then I try to set the selected value like this:
lboxLine.setSelected(lboxLine.getSelectedIndex());
Can you advise please how to make the drop list show the value that has previously been selected?
Answers
Why the '-1' in the first statement?
The first option in the drop down is "Select One" and the others are the options. Therefore to get the real number I take the selected item and deduct one.
The droplist index goes from 0 (zero) to list_size -1 so I suspect you mean +1
lboxLine.setSelected(lboxLine.getSelectedIndex());
This will take the current index as an integer and look for a list value which is of type String. So if the current index is 2 it will look for a list value "2" which is probably not there.