William Miguel
William Miguel

Reputation: 23

how to interact with HTML forms in delphi using TChromium

i need to update the design of a browser in delphi7 I was using the twebbrowser but he had many problems with javascript and navigation.. so i decide to migrate to Chromium. the problem is that I cannot find code on these components. does anyone know which command would be equivalent to this one in tchromium:

OleObject.Document.all.Item ('ElementbyId', 0) .value: = 'edit1.text';

i need to transfer a text from memo to textarea in html form and at the end send a click on the button on the html form. if anyone knows the commands and can share I appreciate it.

Upvotes: 1

Views: 778

Answers (1)

Eric Grange
Eric Grange

Reputation: 6211

A more flexible alternative than DOM access could be to perform this in Javascript, with the ExecuteJavaScript method of TChromium.

From your summary description, the JS could be something like

document.getElementById('yourtextarea').value = <JSON stringified content of your memo>;
document.getElementById('yourform').submit();

Alternatively, you could implement a JS function in your HTML, and call it with ExecuteJavascript, this way there would not be anything specific (besides the function name) on the Delphi side, and the HTML would be free to evolve.

function setTextAreaAndSubmit(value) {
    document.getElementById('yourtextarea').value = value;
    document.getElementById('yourform').submit();
}

Upvotes: 1

Related Questions