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"
Related
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);
}
});
});
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>
I would like to prevent users to remove pre-selected options in my Chosen dropdown (multiple).
<select data-placeholder="Your Favorite Types of Bear" multiple class="chosen-select" tabindex="8">
<option value=""></option>
<option>American Black Bear</option>
<option>Asiatic Black Bear</option>
<option>Brown Bear</option>
<option>Giant Panda</option>
<option selected>Sloth Bear</option>
<option selected>Sun Bear</option>
<option selected>Polar Bear</option>
<option selected>Spectacled Bear</option>
</select>
So I want the Sloth Bear, Sun Bear, Polar Bear and Spectacled Bear selected, and the user can't remove it. How do I go about that?
I think there is no official way to do this.
But let me give you an idea.
Define your select items like this.
<select data-placeholder="Your Favorite Types of Bear" multiple class="my_select_box" tabindex="8">
<option value=""></option>
<option value="1">American Black Bear</option>
<option value="2">Asiatic Black Bear</option>
<option value="3">Brown Bear</option>
<option value="4">Giant Panda</option>
<option value="5" disabled selected>Sloth Bear</option>
<option value="6" disabled selected>Sun Bear</option>
<option value="7" disabled selected>Polar Bear</option>
<option value="8" disabled selected>Spectacled Bear</option>
</select>
Such that I appear like this,
So, now users cannot remove the selected options.
But when you are retrieving the selected values, make sure you are adding the selected values like this.
var selected = $(".my_select_box").val();
var alreadySelected = ['5', '6', '7', '8']
var totalSelected = selected.concat(alreadySelected);
Now, it's ready! You can play with it.
As of my knowledge, there is no perfect way for that. But as a workaround, you can try to disable the options you want to prevent so that they cannot modify their visibility.
You can try the below code:
<select data-placeholder="Your Favorite Types of Bear" multiple class="chosen-select" tabindex="8">
<option value=""></option>
<option>American Black Bear</option>
<option>Asiatic Black Bear</option>
<option>Brown Bear</option>
<option>Giant Panda</option>
<option disabled>Sloth Bear</option>
<option disabled>Sun Bear</option>
<option disabled>Polar Bear</option>
<option disabled>Spectacled Bear</option>
</select>
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
I have a simple search form_tag in a Rails 4 app.
One of the options is a select_tag:
<%= select_tag "plottable[plottable_id]", options_for_select(Plottable.all.map{ |plottable| [ plottable, plottable.id, { 'plottbale-type' => plottable.class } ] }), prompt: 'Select one option'%>
The HTML is generated properly, resulting in:
<select name="plottable[plottable_id]" id="plottable_plottable_id">
<option value="">Select one option</option>
<option plottable-type="Pool" value="3">Pool1</option>
<option plottable-type="Pool" value="4">Pool2</option>
<option plottable-type="Asset" value="33">Asset1</option>
<option plottable-type="Asset" value="34">Asset2</option>
</select>
When submitting the form the plottable-type does not get submitted. Here are the params:
Parameters: {"utf8"=>"✓", "from_time"=>"", "to_time"=>"", "plottable"=>{"plottable_id"=>"35"}, "commit"=>"Search"}
Thanks for your suggestions.
Just try this:
<select name="plottable[plottable_id]" id="plottable_plottable_id">
<option value="">Select one option</option>
<option plottable-type="Pool" value="3">Pool1</option>
<option plottable-type="Pool" value="4">Pool2</option>
<option plottable-type="Asset" value="33">Asset1</option>
<option plottable-type="Asset" value="34">Asset2</option>
</select>
<input type="hidden" name=plottable[type] value="", id="plottable_plottable_type">
$('#plottable_plottable_id').on('change', function(){
var type = $('option:selected', this).attr('plottable-type');
$('#plottable_plottable_type').val(type);
})
you can add hidden field tag by rails code as well
<%= hidden_field_tag "plottable[plottable_type]"%>