Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Auto-complete
Auto-complete
Good Morning !
I'm new to the component, I'd like to know how to complete a field on a web page. Thank you very much in advance.
I tried to use it this way but it did not succeed.
document.getElementById('body').value = 'testing123';
I'm new to the component, I'd like to know how to complete a field on a web page. Thank you very much in advance.
I tried to use it this way but it did not succeed.
document.getElementById('body').value = 'testing123';
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Auto-complete
Hi,
Try modifying the value property in an INPUT element.
Try modifying the value property in an INPUT element.
Re: Auto-complete
Hi salvadordf !
Thanks for the answer ! But I could not solve it, see my code as it was
Chromium1.Browser.MainFrame.ExecuteJavaScript ('document.getElementsByid ("custom-message"). Input = 123456789;');
Nothing happens.
Thanks for the answer ! But I could not solve it, see my code as it was
Chromium1.Browser.MainFrame.ExecuteJavaScript ('document.getElementsByid ("custom-message"). Input = 123456789;');
Nothing happens.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Auto-complete
Let's say that your web page has an INPUT element with an ID attribute set to "myid" like this :
Then you would have to use this :
There are many more JavaScript examples if you search "javascript how to change input value" in google.
Code: Select all
<html>
<body>
<input id="myid" type="text">
</body>
</html>
Code: Select all
document.getElementById("myid").value = "My new value";
Re: Auto-complete
I got results doing this way
Chromium1.Browser.MainFrame.ExecuteJavaScript ('document.getElementById (' 'custom-message' '). SetRangeText (' 'New Value' ')', Chromium1.browser.MainFrame.GetURL (), 0);
Thank you very much
Chromium1.Browser.MainFrame.ExecuteJavaScript ('document.getElementById (' 'custom-message' '). SetRangeText (' 'New Value' ')', Chromium1.browser.MainFrame.GetURL (), 0);


Thank you very much
Re: Auto-complete
Hello !
I was able to fill the field with this code
Chromium1.Browser.MainFrame. ExecuteJavaScript ('document.getElementById (' 'custom-message' '). SetRangeText (' 'New Value' '), Chromium1.browser.MainFrame. GetURL (), 0);
I'm getting the data from a memo, but when the memo has more than one line, when I insert the next line, I'm throwing the text down. That is, it is ending with the text like this:
line 2,
line 1,
line 0.
The correct would be:
line 0,
line 1,
line 2 ...
You may have to place the mouse cursor just after the first line, so when you insert the next line.

I was able to fill the field with this code
Chromium1.Browser.MainFrame. ExecuteJavaScript ('document.getElementById (' 'custom-message' '). SetRangeText (' 'New Value' '), Chromium1.browser.MainFrame. GetURL (), 0);
I'm getting the data from a memo, but when the memo has more than one line, when I insert the next line, I'm throwing the text down. That is, it is ending with the text like this:
line 2,
line 1,
line 0.
The correct would be:
line 0,
line 1,
line 2 ...
You may have to place the mouse cursor just after the first line, so when you insert the next line.

- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Auto-complete
CEF4Delphi is just a Delphi wrapper around the CEF3 API.
CEF3 includes Chromium but CEF4Delphi can't modify how some Chromium's features work.
This is purely a JavaScript question. If you search for "javascript how to add line to textarea" in Google you will find solutions like this one :
https://stackoverflow.com/questions/424 ... javascript
CEF3 includes Chromium but CEF4Delphi can't modify how some Chromium's features work.
This is purely a JavaScript question. If you search for "javascript how to add line to textarea" in Google you will find solutions like this one :
https://stackoverflow.com/questions/424 ... javascript
Re: Auto-complete
There would be a simpler way to populate fields from the site like this example:

I tried this code but I did not succeed.
Does the CEF4 project source have fill-in examples?

I tried this code but I did not succeed.
Code: Select all
Chromium1.Browser.MainFrame. ExecuteJavaScript ('document.getElementById("text8").SetRangeText("7489"))',Chromium1.browser.MainFrame. GetURL (), 0);
Does the CEF4 project source have fill-in examples?
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Auto-complete
No, sorry.
Re: Auto-complete
you can useLaertes wrote: Fri Jun 22, 2018 9:20 pm There would be a simpler way to populate fields from the site like this example:
I tried this code but I did not succeed.
Code: Select all
Chromium1.Browser.MainFrame. ExecuteJavaScript ('document.getElementById("text8").SetRangeText("7489"))',Chromium1.browser.MainFrame. GetURL (), 0);
Does the CEF4 project source have fill-in examples?
getElementsByName();
-------------------
var x = getElementsByName("text8")[0];
if (x != null )
{
alert(x.innerHTML);
x.value=" ";
}
only <IE9 ID has been seen as same as name in an element.