
Result := IndexOfValue(HTMLElement, AOptionValue) If Supports(HTMLDocument.getElementById(AElementID), IID_IHTMLSelectElement, If Supports(ADocument, IID_IHTMLDocument3, HTMLDocument) then If (em(I, I) as IHTMLOptionElement).value = AValue then Source code: function SelectOptionByValue(const ADocument: IDispatch const AElementID,įunction IndexOfValue(const AHTMLElement: IHTMLSelectElement If the with a given value is successfully found (and selected), the return value is the index of that option in a specified drop down list, -1 otherwise.


If no is found, the current drop down list selection is cleared (no item is selected). The following function tries to find, and select (if found) an (a drop down list item) of a given value attribute value in a specified element (drop down list). As a showcase I've made the following function. You can use the IHTMLSelectElement interface with its selectedIndex property for instance.
