No retreievs item 0 when nothing is selected and return the proper value, or lable or content when item is selected

This commit is contained in:
rods%netscape.com 1999-09-10 22:54:24 +00:00
parent b0233d1ada
commit 593a8e8ba7
2 changed files with 18 additions and 0 deletions

View File

@ -488,11 +488,20 @@ nsHTMLSelectElement::GetValue(nsString& aValue)
result = GetOptions(getter_AddRefs(options));
if (NS_SUCCEEDED(result)) {
nsCOMPtr<nsIDOMNode> node;
if (selectedIndex == -1) {
selectedIndex = 0;
}
result = options->Item(selectedIndex, getter_AddRefs(node));
if (NS_SUCCEEDED(result) && node) {
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node);
if (option) {
option->GetValue(aValue);
if (0 == aValue.Length()) {
option->GetLabel(aValue);
if (0 == aValue.Length()) {
option->GetText(aValue);
}
}
}
}
}

View File

@ -488,11 +488,20 @@ nsHTMLSelectElement::GetValue(nsString& aValue)
result = GetOptions(getter_AddRefs(options));
if (NS_SUCCEEDED(result)) {
nsCOMPtr<nsIDOMNode> node;
if (selectedIndex == -1) {
selectedIndex = 0;
}
result = options->Item(selectedIndex, getter_AddRefs(node));
if (NS_SUCCEEDED(result) && node) {
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node);
if (option) {
option->GetValue(aValue);
if (0 == aValue.Length()) {
option->GetLabel(aValue);
if (0 == aValue.Length()) {
option->GetText(aValue);
}
}
}
}
}