Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure SetFieldValue(FormElement: IHTMLFormElement; const FieldName, NewValue: WideString);
- var
- I: Integer;
- Element: IHTMLElement;
- TextElement: IHTMLTextAreaElement;
- InputElement: IHTMLInputElement;
- SelectElement: IHTMLSelectElement;
- begin
- Element := FormElement.item(FieldName, '') as IHTMLElement;
- if Assigned(Element) then
- begin
- if Supports(Element, IID_IHTMLInputElement, InputElement) then
- begin
- // Make the change below to catch checks and radios.
- if (InputElement.type_ = 'checkbox') or (InputElement.type_ = 'radio') then
- begin
- if newValue = 'Y' then
- InputElement.checked := True
- else
- InputElement.checked := False;
- end
- else
- InputElement.value := newValue;
- end
- else
- if Supports(Element, IID_IHTMLSelectElement, SelectElement) then
- begin
- for I := 0 to SelectElement.length - 1 do
- if (SelectElement.item(I, I) as IHTMLOptionElement).text = NewValue then
- begin
- SelectElement.selectedIndex := I;
- Break;
- end;
- end
- else
- if Supports(Element, IID_IHTMLTextAreaElement, TextElement) then
- TextElement.value := newValue;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment