Want options under select in IE, one by one - vba

I want option value in MsgBox one by one, like:
Week:-1 12-May-2019
Week:-2 19-May-2019
Week:-3 26-May-2019
Week:-4 02-Jun-2019
Html:
<table id="tblMain" cellspacing="1" class="table table-bordered table-hover dataTable" border="0" style="border-color:SaddleBrown;font-size:Small;">
<tr style="background-color:#3C8DBC;">
<td colspan="2"><select name="cmbWeeks" onchange="javascript:setTimeout('__doPostBack(\'cmbWeeks\',\'\')', 0)" id="cmbWeeks" class="form-control" style="font-family:Arial;font-size:9pt;">
<option value="12-May-2019">Week:-1 12-May-2019</option>
<option value="19-May-2019">Week:-2 19-May-2019</option>
<option value="26-May-2019">Week:-3 26-May-2019</option>
<option value="02-Jun-2019">Week:-4 02-Jun-2019</option>
<option selected="selected" value="">[Select Week]</option>
</select><br />
<select name="ddllocation" onchange="javascript:setTimeout('__doPostBack(\'ddllocation\',\'\')', 0)" id="ddllocation" class="form-control" style="font-family:Arial;font-size:9pt;">
<option selected="selected" value="GPC">GPC</option>

You can try the following css selector combination assuming your iframe reference is correct
Dim options As Object, i As Long
Set options = ie.document.getElementsByTagName("iframe")(0).contentDocument.querySelectorAll("[name=cmbWeeks] option")
For i = 0 To options.Length - 1
MsgBox options.Item(i).Value
Next

Related

Insert multiple records at once from a table

I have this table which is loaded with data from the database and what the user has to do is select the one they want and fill in the data from both the select and the input, and that data can be saved in separate records. It is the first time I work with this so I don't know a bit about the process.
Currently my view I have it this way
<tbody>
#foreach($vsoftware as $cli)
<tr>
<td style="text-align: center;vertical-align: middle">
<input type="checkbox" name="id_software[]" value="{{$cli->id_software}}">
</td>
<td style="text-align: center;vertical-align: middle">{{ $cli->nom_soft}}</td>
<td style="text-align: center;vertical-align: middle">{{ $cli->marca}}</td>
<td style="text-align: center;vertical-align: middle">{{ $cli->nombre_ver}}</td>
<td style="text-align: center;vertical-align: middle">{{ $cli->num_version}}</td>
<td style="text-align: center;vertical-align: middle">
<select class="mr-sm-2" id="inlineFormCustomSelect" name="id_tipo_venta[]" >
<option value="" selected>sale...</option>
<option value="1">Key</option>
<option value="2">Instal</option>
<option value="3">Key + Instal</option>
<option value="3">Viruz</option>
</select>
</td>
<td style="text-align: center;vertical-align: middle">
<input name="obs_software[]" class=" form-control" type="text">
</td>
</tr>
#endforeach
my controller I try to form it like this:
$soft_instal = new Software_instalacion;
$soft_instal->id_instalacion = $instalaciones->id;
$soft_instal->id_historial = $historial->id;
$soft_instal->id_software = $request->id_software;
$soft_instal->id_usuario = $request->id_usuario;
$soft_instal->id_tipo_venta = $request->id_tipo_venta;
$soft_instal->obs_software = $request->obs_software;
dd($soft_instal);
$soft_instal->save();
The answer that the dd gives me is:
response
And the idea is that you can store it like this in the database:
way to save
The simplest way is that you can loop through your checkbox array.
Here check out the #Tim Lewis answer:
submit multiple arrays from html and combine their attribute into seperate collections and store in Laravel App
Also read about Laravel Mass Assignment:
https://laravel.com/docs/8.x/eloquent#mass-assignment
you can use
foreach($request->input('id_software') as $index => $item) {
$soft_instal = new Software_instalacion;
$soft_instal->id_instalacion = $instalaciones->id;
$soft_instal->id_historial = $historial->id;
$soft_instal->id_software = $item;
$soft_instal->id_usuario = $request->input('id_usuario')[$index];
$soft_instal->id_tipo_venta = $request->input('id_tipo_venta')[$index];
$soft_instal->obs_software = $request->input('obs_software')[$index];
$soft_instal->save(); }

How to display multi dimensional array into the multiple dropdown menu?

I am working in multiple dropdown menu. I have created an array from php and it looks like this:
https://api.myjson.com/bins/1emzic
Now from this json I want to display 4 dropdown menu.
In the first drop down I need to display
"FS A", "FS MT" and "FS OTHER"
Based on the first selection I need to display its related data in second third and fourth and so on as I add in my data.
This is what I need to bind
<select [(ngModel)]="first" id="first">
<option value="" disabled selected>select a category</option>
<option *ngFor="let item of first_list" [value]="item.category">{{item.category}}</option>
</select>
<br>
<select [(ngModel)]="second" id="second">
<option value="" disabled selected>select a category</option>
<option *ngFor="let item of first_list" [value]="item.category">{{item.category}}</option>
</select>
<br>
<select [(ngModel)]="third" id="third">
<option value="" disabled selected>select a category</option>
<option *ngFor="let item of first_list" [value]="item.category">{{item.category}}</option>
</select>
<br>
<select [(ngModel)]="four" id="four">
<option value="" disabled selected>select a category</option>
<option *ngFor="let item of first_list" [value]="item.category">{{item.category}}</option>
</select>
Here is my json data
{"FS A":{"BKK":{"BKK PULL":{"BKK SR1":[]},"BKK PUSH":{"BKK BCDE1":[],"BKK BAKE SE1":[]}},"RSM2":{"CHIANGMAI":{"CMI WS SE1":[],"CMI WS SE2":[]},"NORTH":{"NO1 SE1":[],"NO2 SEPLUS1":[],"NO3 SE1":[]},"ASM HOTEL BKK":{"BKK HO 5STARS1":[],"BKK HO SR1":[],"BKK HO SR2":[],"BKK HO SR3":[]}}},"FS MT":{"FSR1":{"FSA1":{"FS MAKRO":[]}},"FSR2":{"FSA2":{"FS FOODLAND":[],"FS GAS STATION":[],"FS VILLA MARKET JP":[],"SIAM FOODSERVICE":[]}},"FS LOCAL EXP":{"FS LOCAL EXP BKK":{"FS LOCAL EXP BKK":[]},"FS LOCAL EXP CD":{"FS LOCAL EXP CD":[]},"FS LOCAL EXP MM":{"FS LOCAL EXP MM":[]}}},"FS OTHER":{"FS OTHER":{"FS OTHER":{"FS OTHER":[]}}}}
Can anybody help me in this?
Here I am working:
https://stackblitz.com/edit/angular-dsylxi
You need to define the dependency on each other and based on that you can fill the models and its options. I will go for generic solution which can be applied with one function and works for all the drop-downs.
This are the model variables you need
wholeList:any = [];
first:any = [];
second:any = [];
third:any = [];
four:any = [];
firstModel = ''
secondModel = ''
thirdModel = ''
fourModel = ''
Then first you fill the first dropdown
this.testService.get_data().subscribe(
res => {
this.wholeList = res;
this.first = Object.keys(this.wholeList).map(a=> a);
console.log("res", this.first);
},
err => {
console.log(err);
}
)
Then in the view you need to fire a dependency which should look like this, note that I am defining dependency ChangeDropdown(this.wholeList[firstModel],'second')"
<select [(ngModel)]="firstModel" id="first" (ngModelChange)="ChangeDropdown(this.wholeList[firstModel],'second')">
<option value="" disabled selected>select a category</option>
<option *ngFor="let item of first" [value]="item">{{item}}</option>
</select>
<br>
<select [(ngModel)]="secondModel" id="second" (ngModelChange)="ChangeDropdown(this.wholeList[firstModel][secondModel],'third')">
<option value="" disabled selected>select a category</option>
<option *ngFor="let item of second" [value]="item">{{item}}</option>
</select>
<br>
<select [(ngModel)]="thirdModel" id="third" (ngModelChange)="ChangeDropdown(this.wholeList[firstModel][secondModel][thirdModel],'four')">
<option value="" disabled selected>select a category</option>
<option *ngFor="let item of third" [value]="item">{{item}}</option>
</select>
<br>
<select [(ngModel)]="fourModel" id="four">
<option value="" disabled selected>select a category</option>
<option *ngFor="let item of four" [value]="item">{{item}}</option>
</select>
and finally one common function which will update the models
ChangeDropdown = (value,dropdownName) =>{
this[dropdownName] = Object.keys(value).map(a=>{
return a;
})
}
Demo

How to sort a table by using dropdown menus (starting date - end date) for VueJS?

I am new to VueJS. How would I be able to sort a table using VueJS? I have four dropdown menus (to select starting month and starting year to an ending month and year) then display/update that to the table? I am grabbing data from a Sqlite database btw. My goal is to select a timeframe, then have it display in the table. I have been researching and watching videos on Youtube. But I have not been able to find a solution. Any help would be appreciated.
<template> <div class="time">
<h2></h2>
<center>
<span>Select Timeframe: </span>
<select v-model="startMonth">
<option disabled value=" ">Month</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select v-model="startYear">
<option disabled value=" ">Year</option>
<option>2017</option>
<option>2018</option>
</select> -
<select v-model="endMonth">
<option disabled value=" ">Month</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select v-model="endYear">
<option disabled value=" ">Year</option>
<option>2017</option>
<option>2018</option>
</select>
<button>Go</button> <br><br>
<span>start: {{ startMonth }}</span>
<span>{{ startYear }} - </span>
<span>{{ endMonth }}</span>
<span>{{ endYear }}</span>
<table class = "table table-bordered table-sptried table-condensed">
<thead>
<tr>
<th>Month</th>
<th>Day</th>
<th>Year</th>
<th>Time</th>
<th>Activity</th>
</tr>
</thead>
<tbody>
<tr v-for="client in clients" :key="client.id">
<td>{{client.Months}}</td>
<td>{{client.Days}}</td>
<td>{{client.year}}</td>
<td>{{client.Time}}</td>
<td>{{client.Activity}}</td>
</tr>
</tbody>
</table> </center> </div> </template>
You can use computed feature of Vue. Instead of reading directly from clients, you can create computed variable (for example sortedClients). Then you can do anything in this function
For example:
computed: {
sortedClients: function() {
function compare(a, b) {
const aTime = <get time from a>
const bTime = <get time from b>
if (aTime < bTime)
return -1;
if (bTime > bTime)
return 1;
return 0;
}
return this.clients.sort(compare);
}
}
For time conversion, you can use https://momentjs.com/

VBA to click on a button in IE with no ID, Name, ClassName

I need to click on a button in IE. I tried few options with no success. Everything i tried are using TagName/ ClassName/ Name/ ID. But I don't find any of these in the below.
<FORM method=post name=frmSearch action=searchResultsSummary>
<INPUT type=hidden value=GMT+01:00 name=clitz>
<DIV style="MARGIN-LEFT: 30px">
<DIV style="MARGIN-BOTTOM: 10px; FONT-WEIGHT: bold">Common Criteria</DIV>
<TABLE style="MARGIN-LEFT: 20px" cellSpacing=5 cellPadding=0 border=0>
<TBODY>
<TR>
<TD id=oDocumentCategoryCell style="HEIGHT: 22px" colSpan=3 noWrap>Document category:</TD>
<TD colSpan=3 align=left>
<SELECT style="DISPLAY: block" name=docCategory old_value="2">
<OPTION value=%>Any Category</OPTION>
<OPTION value=FINANCE>Finance Document</OPTION>
<OPTION selected value=INBOUND>Inbound Document</OPTION>
<OPTION value=PROCESS>Internal Process</OPTION>
<OPTION value=OUTBOUND>Outbound Document</OPTION>
</SELECT>
</TD>
<TD style="WIDTH: 15px"></TD>
<TD>
<INPUT onclick="javascript:if (!validateSearchForm()) return;if (!checkCountOfDays()) return; addRefKeysToForm(frmSearch); frmSearch.submit();" style="WIDTH: 100px" type=button value=Search>
</TD></TR>
<TR>
<TD style="HEIGHT: 22px" colSpan=3 noWrap>Document type:</TD>
<TD colSpan=3 align=left>
<SELECT style="DISPLAY: block" name=docType old_value="0">
<OPTION selected value=%>Any Type</OPTION>
<OPTION value=CSN_ORD_VALID>CSN Order Validation</OPTION>
<OPTION value=CREDIT_ORD>Credit Order</OPTION>
<OPTION value=EOI_ORDCPY>EOI Order Copy</OPTION>
<OPTION value=LEASE_ORD>Lease Order</OPTION>
<OPTION value=ORDER_REPORT>Order Load Report</OPTION>
<OPTION value=TRADE_ORD>Trade Order</OPTION>
<OPTION value=WATSON>WATSON Quote</OPTION>
<OPTION value=WATSON_UPDATE>WATSON Update Quote</OPTION>
<OPTION value=WNGQ>WNGQ Request</OPTION></SELECT> </TD></TR>
<TR>
I tried going by input tags and it is not working.
I used the below code. It clicks on the button i want but it is not considering the values i gave before clicking on submit button.
Dim btnInput As MSHTML.HTMLInputElement
Dim frm As MSHTML.IHTMLElementCollection
Application.ScreenUpdating = True
Set frm = ie.Document.getElementsByName("frmSearch")
For Each btnInput In frm
If btnInput.Value = "frmSearch.submit()" Then
btnInput.submit
Exit For
End If
Next btnInput
Can some one help me on how to click on the button.
As #Tim Williams suggest, this should work document.querySelector("input[value=Search]").
If this still doesn't return the correct input element then the selector can be made more specific according to the DOM tree where the searched input is located, e.g. like this.
' Add reference to Microsoft Internet Controls (SHDocVw)
' Add reference to Microsoft HTML Object Library
Dim inputElement As HTMLInputElement
Set inputElement = doc.querySelector( _
"div[class=main] div[id=inner] table input[type=button][value=Search]")
If Not inputElement Is Nothing Then
inputElement.Click
End If
HTML
<div class="main">
<div id="inner">
<table>
<tbody>
<tr>
<td>
<INPUT onclick="alert('This is the corect one');"
style="WIDTH: 100px"
type=button
value=Search>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<INPUT onclick="alert('No this is not the searched one');"
style="WIDTH: 100px"
type=button
value=Search>
EDIT:
Not sure if I understand your problem correctly.
To select the INPUT element this selector can be used:
Set inputElement = doc.querySelector( _
"form[name=frmSearch] table tbody tr td input[type=button][value=Search]")
To set the value attribute setAttribute() function can be used. To check value attribute getAttribute() function can be used.
If Not inputElement Is Nothing Then
inputElement.setAttribute "value", "some-new-value"
If inputElement.getAttribute("value") = "some-new-value" Then
inputElement.Click
End If
End If

org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "td"

hii all i am very new to automation
my problem is i am getting an error
org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "td"
when i am trying to select an option from dropdown list
this is my sourch code
public void CompanyFilters_Fn() {
// TODO Auto-generated method stub
_driver.findElement(By.xpath(".//*[#id='company._idCell']")).click();
Select CompanyOptions = new Select(_driver.findElement(By.xpath(".//*[#id='company._idCell']")));
CompanyOptions.deselectAll();
CompanyOptions.selectByIndex(5150);
CompanyOptions.selectByIndex(5003);
}
this is my html code
<td id="company._idCell" class="filterValue filterActive filterChanged firepath-matching-node" onclick="showInputElement('pre.myProjectsForm.company._id', this, null, 'auto'); return false;" title="Select to filter by Company">Company: [No Company]</td>
these are the options
<div id="divSelect" class="inputElement" style="left: -1000px; top: 212px; width: auto; height: 20px;">
<select id="inputSelect" size="5" style="width: auto; visibility: visible;" multiple="" disabled="">
<option value="-1">Any</option>
<option value="0">[No Company]</option>
<option value="5150">123</option>
<option value="5203">AutoCarLoanCompany</option>
<option value="5205">Company_rahul</option>
<option value="5202">CreditCardCompany</option>
<option value="5003">IBM</option>
<option value="5204">June</option>
<option value="5300">other companyyyyy</option>
<option value="5001">qa</option>
<option value="5101">Rahul</option>
</select>
</div>
Plzzz help me to get out of this...
The error message is very descriptive, you've given it a td when it expects a select (rightly so).
So here:
Select CompanyOptions = new Select(_driver.findElement(By.xpath(".//*[#id='company._idCell']")));
You need to change this to give it the select:
Select CompanyOptions = new Select(_driver.findElement(By.id("inputSelect")));