1

I am using TChromium component on Delphi 10. I need to transfer the text from TMemo to a textarea in html and simulate a click on button on this page.

I have been try it, but doens't work

chromium1.Browser.MainFrame.ExecuteJavaScript('document.all(id_4).value='+Memo1.text+';', '', 0);
Chromium1.Browser.MainFrame.ExecuteJavaScript('id_2.click();', '', 0);

Basically i need this code bellow but using TChromium in Delphi 10. This code bellow is on delphi7 using TWebBrownser.

WebBrowser1.OleObject.Document.all.Item('id_4', 0).value := memo1.Text;
WebBrowser1.OleObject.Document.all.Item('id_2', 0).click;
2
  • "It doesn't work" is not enough to help you. What happens? Do you get and error? Commented Apr 11, 2021 at 15:50
  • when i use the code shown i can't send the text from the Memo1 to the textarea in html. This code does not perform the task I need. Commented Apr 12, 2021 at 0:31

1 Answer 1

1

If your Memo1 contains the text:

With space in it.

...then:

document.all(id_4).value=With space in it.;

...is not valid JavaScript, because With is undefined. And the following three tokens plus the dot, too. You have to assign text to it, so in Delphi you have to use:

'document.all( id_4 ).value= "'+ Memo1.Text+ '";'

...as literal, because then it becomes valid JavaScript:

document.all( id_4 ).value= "With space in it.";

Of course: you have to take care of Memo1's text if it contains a " itself.

Sign up to request clarification or add additional context in comments.

3 Comments

That code didn't work either. I need to transfer the Memo1 text to the html textarea on this page: form.jotformz.com/90325850930657 and right after that, simulate a click to send
It's up to you to make sure id_4 exists as a variable in the JavaScript context. But if you mean a literal 'id_4' instead then I'm afraid you haven't grasped what this answer is about and just copied code.
Amigojack this is not javascript... This is Just sample html: <textarea id="id_4" name="id_4" rows="4" cols="50"> My text transfered from memo1 to here. </textarea>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.