I have a simple function that displays the value that a user has selected from a drop down list of items:
function DisplayChoice(){
for ( var i = 0; i < document.curveForm.CurrencyList.length; i++){
if ( document.curveForm.CurrencyList.options.selected == true){
alert(document.curveForm.CurrencyList.options.text);
}
}
}
but for some reason if CurrencyList has more than one element in it the user can not select the first element in the list unless of course they select another element in the list first i.e. if the CurrencyList is A, B, C, D the users have to select B, C or D first before they can select A.
The same applies to a CurencyList that has only one element in it. If the user clicks on the only element then the alert window never pops up on the screen.
Have I done something really stupid in this code?
function DisplayChoice(){
for ( var i = 0; i < document.curveForm.CurrencyList.length; i++){
if ( document.curveForm.CurrencyList.options.selected == true){
alert(document.curveForm.CurrencyList.options.text);
}
}
}
but for some reason if CurrencyList has more than one element in it the user can not select the first element in the list unless of course they select another element in the list first i.e. if the CurrencyList is A, B, C, D the users have to select B, C or D first before they can select A.
The same applies to a CurencyList that has only one element in it. If the user clicks on the only element then the alert window never pops up on the screen.
Have I done something really stupid in this code?