2

How can I change value of combobox using Tchromium Delphi? Version Tchromimum DCEF3

<td class="droplabels" nowrap="nowrap">Лист</td>
<td colspan="3">
   <div class="ui-widget">
      <select id="sheet" name="sheet" style="font-size:0.7em;width:761px;" 
         class="form_select" onchange="showSheet(this.value);">
             <option value="1" selected="selected">Account List </option>
             <option value="2">Merchant list</option>
      </select>
   </div>
</td>

try this but not worked... Chromium1.Browser.MainFrame.ExecuteJavaScript('document.getElementById("sheet").selectedIndex=2;', 'about: blank', 0); Chromium1.Browser.MainFrame.ExecuteJavaScript('document.getElementById("providerField").onchange();', 'about: blank', 0);

Ulugbek
  • 43
  • 1
  • 7
  • Which version of Chromium are you using ? – TLama Mar 12 '13 at 12:23
  • Last version from svn/truck – Ulugbek Mar 13 '13 at 04:16
  • I meant more if it's [`CEF1`](https://code.google.com/p/delphichromiumembedded/) or [`CEF3`](https://code.google.com/p/dcef3/) wrapper for Delphi. Could you [`edit your question`](http://stackoverflow.com/posts/15354828/edit) and include this information into your question, please ? – TLama Mar 13 '13 at 07:26

1 Answers1

0

There's an ExecuteJavascript on it. So you can manipulate everything on it with Javascript.
If you want to change that combobox value , then change it with using DOM.Get its id using "document.getElementById", then change its selectedIndex by accessing its selectedIndex.
But , that'll not triggering onChange event. So , you need to call it manually using javascript again.

Here's the code to change it's selectedIndex :

Chromium1.Browser.MainFrame.ExecuteJavaScript('document.getElementById("sheet").selectedIndex='+comboboxIndex+';', 'about: blank', 0);

To trigger onChange event manually :

Chromium1.Browser.MainFrame.ExecuteJavaScript('document.getElementById("providerField").onchange();', 'about: blank', 0);    

Change Chromium1 to your TChromium variable object name.

Here's for more information about Select
http://www.w3schools.com/jsref/dom_obj_select.asp

If you don't know anything about DOM , read it here
http://www.w3schools.com/htmldom/default.asp In simple way , you just need to get the DOM object of it then do what you want by accessing and modifying its properties

Sorry for my bad English.
edited

  • You question is not clear at all. You need to be clear with you problem and what you are looking for should be bit more detailed. – Guru Kara Mar 14 '13 at 06:21
  • i think he just want to change the combobox value that appear on the chromium browser. am i wrong? – Raizal I.N. Pregnanta Mar 14 '13 at 06:28
  • You are not wrong, but you have to clearly state your assumption and give answer to that. If you can edit the answer and be detailed it will be great – Guru Kara Mar 14 '13 at 06:40
  • not worked Crm.Browser.MainFrame.ExecuteJavaScript('document.getElementById("sheet").selectedIndex=4;', 'about: blank', 0); crm.Browser.MainFrame.ExecuteJavaScript('document.getElementById("providerField").onchange();', 'about: blank', 0); – Ulugbek Apr 28 '13 at 20:10
  • @Ulugbek did you find anything? I have the same problem. – Kermia Mar 23 '15 at 08:15