How change value of combobox in Delphi Tchromium? - delphi

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);

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

Related

Why is checkbox in Datatable triggering CREATE action

I have an Ajax Datatable in Rails, and a column with a Select_all checkbox.
<th class="check_box">
<input type="checkbox" name="people-datatable-select_all" id="people-datatable-select_all" value="1" title="Tout cocher/Tout décocher" />
</th>
But when the user click on the select all, it briefly select all the rows, then trigger a reload of the table, how can I prevent the reload from happening, so I can collect all the checked boxes and trigger a custom action please?
My JS Script look as :
$("#people-datatable-select_all").change(function() {
if(this.checked) {
$("input:checkbox").prop("checked", this.checked);
} else {
$(".input:checkbox").prop("checked", false);
}
});
What is the best way to stop that reload please ?
It sounds like your check all function is calling a datatable reload. You might try adding table.ajax.reload( null, false ); in your JS script with table being the datatable variable.
https://datatables.net/reference/api/ajax.reload()

How to select option from datalist in Cypress

I have a datalist with some options and I want to select the first one using Cypress. How do I do that?
I need to click on the option, simply typing in the value is not what I want, because when an option is selected, a Javascrip function is called. So it's more like How do I click on a datalist option using Cypress?
cy.get('#foods').first().click({force:true})
Does not work.
Presuming the Ruby datalist is like this
<datalist id="foods">
<% Foods.all.each do |food| %>
<option value="<%= food.name %>"></option>
<% end %>
</datalist>
gives this in the DOM
<datalist id="foods">
<option value="Lamb">
<option value="Beef">
<option value="Fruit">
</datalist>
You can get the first option with
cy.get('#foods') // gets the outer datalist
.find('option') // returns all options inside
.first() // take the first
.click({force:true})
for other option, e.g 3rd
cy.get('#foods') // gets the outer datalist
.find('option') // returns all options inside
.eq(2) // take the third
.click({force:true})
The {force:true} is only required because the list is not opened.
It may be better to open it first and click without force, as a page error can be masked by using {force:true}.
cy.get('#foods') // gets the outer datalist
.invoke('show') // open list
.should('be.visible')
.find('option') // returns all options inside
.first() // take the first
.click()

How to get selected option in change callback of AngularDart component

I want to use a select HTML element to filter items in a table. For that I have a model value selectedCategoryId and event callback onFilterCategory for the change event. But when callback gets called the value selectedCategoryId is null.
I have the following HTML snippet:
<select id="category"
class="form-control"
[(ngModel)]="selectedCategoryId"
(change)="onFilterCategory()">
<option *ngFor="let category of categories"
value="{{category.id}}">
{{category.name}}
</option>
</select>
And the following dart snippet:
void onFilterCategory() {
print('onFilterCategory');
print('this.selectedCategoryId: ' + this.selectedCategoryId);
}
Do I need to use another callback?
ngModelChange is the event and $event the value
(ngModelChange)="onFilterCategory($event)"
with
void onFilterCategory(String value) {
Because you have 2-way binding
[(ngModel)]="selectedCategoryId"
you can also use
(ngModelChange)="onFilterCategory()"
with the onFilterCategory() as it is in your question.
The change event doesn't work because it fires too early - before [(ngModel)]="selectedCategoryId" was able to update selectedCategoryId.

angular 2 Retrieving values from check boxes

I have two check boxes and they are populating when the user is selected, but I now need to check the values and return them before saving them back to database in case they have been changed, below is my plunker with my working code if you select a tradesman from the drop down the ticket boxes are populated.
If someone could advise how I can get check the tick box values that would be great, this is what I have tried but I am missing something:
<input type="input" name="adminis" id="adminis" class="form-control" [(ngModel)]="tradesman.user_roles"/>
Plunker demo
To find whether a checkbox value is changed or not, you can use (change) attribute.
<input type="checkbox" [checked]="tradesman?.user_roles?.includes('Administrator') ? true : false" value="Administrator" (change)="valueChanged($event)"/>Admin
<input type="checkbox" [checked]="tradesman?.user_roles?.includes('General User') ? true : false" value="General User" (change)="valueChanged($event)" />General
In your component, you can manage the data using the event passed.
valueChanged(e:any){
/* e.target.name - for getting the changed field name */
/* e.target.checked - for getting the value - true(checked)/false(unchecked) */
}
Then you can update your array or whatever with this new value.

jQuery mobile change select value by script fail (nothing happens)

I'm desperately trying to change the option value in of a select at pageshow and it does nothing.
I don't know how to change it
<select name="sliderAutoConnect" id="sliderAutoConnect" data-role="slider">
<option value="1">Off</option>
<option value="2">On</option>
</select>
and the script :
$("#sliderAutoConnect option[value=2]").attr('selected', 'selected');
$('#sliderAutoConnect').selectmenu('refresh');
You need to refresh the slider widget instead of selectmenu. Try this instead:
$('#sliderAutoConnect').slider('refresh');
Everything else worked for me when i tested it. I just changed that one line.

Resources