using excel vba to change the value of a dropdown menu that after activate and populate a second dropdown menu - forms

I am writin a macro excel to fill out a form in a web site.
My issue is that I can valorize the drop down menĂ¹ (is a select command) but this should activate and populate a second drop down menĂ¹.. that does not appear
The code is
' this is the first select to choice the REGION
<select name="ctl00$cp$ddlRegion" id="ctl00_cp_ddlRegion">
<option value="">seleziona...</option>
<option value="13">Abruzzo</option>
<option value="17">Basilicata</option>
<option value="18">Calabria</option>
<option value="15">Campania</option>
<option value="08">Emilia-Romagna</option>
<option value="06">Friuli-Venezia Giulia</option>
<option value="12">Lazio</option>
<option value="07">Liguria</option>
<option value="03">Lombardia</option>
</select>
'the second select, depending from the region above, valorize the CITY
<select name="ctl00$cp$ddlProvince" id="ctl00_cp_ddlProvince">
<option value="">seleziona...</option>
<option value="070">Campobasso</option>
<option value="094">Isernia</option>
</select>
MY CODE IS:
IE.document.ALL("ctl00$cp$ddlRegion").Value = "03" ' that is LOMBARDIA
but after this line the value it appear.. but the second select does not activate.
I have tried with
IE.document.ALL("ctl00$cp$ddlRegion").focus
IE.document.ALL("ctl00$cp$ddlRegion").click
IE.document.ALL("ctl00$cp$ddlRegion").fireEvent ("onchange")
IE.document.ALL("ctl00$cp$ddlProvince").focus
IE.document.ALL("ctl00$cp$ddlProvince").disabled = false
BUT NOTHING... does anybody knows why......
thank you in advance
Alex

Related

how to forbid to screen reader read options length in select

CromeVox screen reader reads wrong options length for select.
Technically right, but not what I need.
<select name="month" id="month">
<option value="" disabled selected style="display: none;">Month</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
It reads "combobox two of thirteen"
How to tell screen reader to not read list length at all or force it read "combobox two of twelve"?
https://jsfiddle.net/mrs_kva/5wk6xjt9/
I cant remove empty option.
UPD:
on w3.org presented example have this issue too
see here.
Despite there are 12 fruits in select reader says "13"

Add optgroup dynamically to an existing select

I have an existing select with 5 options and a default blank value. I want to add an optgroup to the first 3 values and another optgroup to the last two options.
<select id="cityDropdown">
<option selected="selected" value="" label=" "> </option>
<option value="1000">Tokyo</option>
<option value="1001">Kyoto</option>
<option value="1002">Osaka</option>
<option value="1003">Incheon</option>
<option value="1004">Busan</option>
</select>
I want my select to look like this
<select id="cityDropdown">
<optgroup label="Japan">
<option value="1000">Tokyo</option>
<option value="1001">Kyoto</option>
<option value="1002">Osaka</option>
</optgroup>
<optgroup label="SoKorea">
<option value="1003">Incheon</option>
<option value="1004">Busan</option>
</optgroup>
</select>
Below is my existing code which no longer works since the values are no longer even.
$(document).ready(function() {
var select = $('#cityDropdown');
var opt1, opt2;
$('option', select).each(function(i) {
if (i % 2 === 0) {
opt1 = $(this);
} else {
opt2 = $(this);
var optgroup = $('<optgroup/>');
optgroup.attr('label', label);
opt2.add(opt1).wrapAll(optgroup);
}
});
});

How do I update which option is selected based on EJS

I have a express server that passes in information from a mongo db into a ejs file. I am trying to update an item in the db. I want to have the current item information entered in as placeholders.
Here is the ejs code I'm not sure how to select one option based on the info from the db.
<select name="category" id="Category" placeholder="<%= product.category %>">
<option value="vegetable">Vegetable</option>
<option value="fruit">Fruit</option>
<option value="dairy">Dairy</option>
</select>
I understand that to have an option as the placeholder you generally have to use <option selected>
Any suggestions are much appreciated.
Use a Ternary Operator
<select name="category" id="Category">
<option value="vegetable" <%=product.category==='vegetable' ? 'selected' : '' %>>Vegetable</option>
<option value="fruit" <%=product.category==='fruit' ? 'selected' : '' %>>Fruit</option>
<option value="dairy" <%=product.category==='dairy' ? 'selected' : '' %>>Dairy</option>
</select>

validation on if condition in Laravel

How to give a validation on if condition like in my project case there are two inputs one is deal type and one is event name .so i have to give a condition like if deal type is single then i have to validate that event name otherwise no.
Here is my view :
<select name="deal_type">
<option value="">--Select--</option>
<option value="annual">Annual</option>
<option value="single">Single</option>
</select>
<select name="eventname">
<option value="">--Select--</option>
<option value="event1">Event1</option>
<option value="event2">event2</option>
</select>
my validation request.php :
public function rules()
{
return [
'deal_type'=>'required',
'eventname'=>'required_if:deal_type,single'
];
}
I was trying something like above but it is not working .Any suggestions please.

jQuery addClass using input select

Im a bit of a jQuery novice.
I have 5 options in a drop down menu.
I want to add a class in a div depending on which option is selected.
This class will then change the layout of the content using CSS.
Here is an example if it helps!
Thanks
<form>
<select>
<option id="1">layout 1</option>
<option id="2">layout 2</option>
<option id="3" selected>layout 3</option>
<option id="4">layout 4</option>
<option id="5">layout 5</option>
</select>
<div class="3">styled content</div>
</form>
You can use the ".attr()" to set the class attribute of the div onchange.
You're best to change the option id to value first. then:
$("select").change(function() {
$("div").attr("class", $(this).val());
});
(EDIT) Change it to:
$("select#np_blog_layout").change(function() {
$("div#changebox").attr("class", $(this).val());
});
What 'rudeovski ze bear' said, but if you still want to set it to the div's class to the selected elements id, here it is.
$('select').change(function() {
$('div').attr('class', $(this).attr('id'));
});
First off, you don't have to use id to your options. Put the values in value attribute. Put ID to your div and select so you can select them using jQuery.
<form>
<select Id="selectElement">
<option value="1">layout 1</option>
<option value="2">layout 2</option>
<option value="3" selected>layout 3</option>
<option value="4">layout 4</option>
<option value="5">layout 5</option>
</select>
<div id="styledContent" class="3">styled content</div>
</form>
On JS
//Attach event handler to select element's onchange event
$('#SelectElement').bind("change",changeStyle);
//The event handler
function changeStyle()
{
//Set class to selected value
$('#styledContent').class($('#SelectElement').val());
}