Is it possible for a datalist to have scrolldown? - html

I'm new to HTML and trying to use a datalist. I need to limit it to display only 5 items and the rest to be viewed using scrolldown. Is there any way?
My code :
<form>
<input list="Android" name="Android">
<datalist id="Android">
<option value="Alpha">
<option value="Beta">
<option value="Cupcake">
<option value="Doughnut">
<option value="Eclairs">
<option value="Fryo">
<option value="GingerBread">
<option value="HoneyComb">
<option value="Icecream Sandwich">
<option value="Jelly Bean">
<option value="Kitkat">
<option value="Lollipop">
<option value="Marshmallow">
<option value="Nougat">
</datalist>
<input type="submit">
</form>
This is the output of my code
Thanks in advance!

Well, that's not possible to do, the datalist layout is defined by the browser the same as it does with the select tag and there is very little flexibility on customization. Your example comes from Chrome; in Firefox, it shows only 6 items and on Edge it shows something similar with limited size as well.
The proposed solution is using something else rather that using datalist, if you can't live with the datalist design Chrome offers, try some other component with a similar behavior, like dropdown select, autocomplete, autosugest, typeahead, etc.

Related

How can I make the input datalist scrolling by the current selection?

I'm using the native input element with datalist, when I use the arrow key to pick the selection, the scrollbar didn't follow my focus.
How can I make it?
<label for="ice-cream-choice">Choose a flavor:</label>
<input list="ice-cream-flavors" id="ice-cream-choice" name="ice-cream-choice" />
<datalist id="ice-cream-flavors">
<option value="Chocolate">
<option value="Coconut">
<option value="Mint">
<option value="Strawberry">
<option value="Vanilla">
<option value="Chocolate">
<option value="Coconut">
<option value="Mint">
<option value="Strawberry">
<option value="Vanilla">
<option value="Chocolate">
<option value="Coconut">
<option value="Mint">
<option value="Strawberry">
<option value="Vanilla">
<option value="Chocolate">
<option value="Coconut">
<option value="Mint">
<option value="Strawberry">
<option value="Vanilla">
</datalist>
You did everything right. Since the <datalist> itself is a replaced element, there is not much that you can do.
This is a known bug in the Chrome browser: Issue 889960: HTML 5 Datalist does not scoll when using the keyboard , open since April. You should definitely express your interest in the issue over there.
I cannot decide the criticality of this issue for you, neither do I know whether you could help fix it upstream in the Chromium code base.
Additionally, the Chrome implementation seems to have more issues concerning accessibility of datalist: Issue 1130496: datalist is not accessible (zoom, focus visibility, contrast adjustment).
So if you need to fix this, and you cannot do so upstream, you’ll need to implement the listbox yourself. You might want to track the bugs, and once they are fixed you roll back your custom solution.
The Combobox pattern from the ARIA Authoring Practices Guide (APG) gives an idea of how such a combobox should behave.
The Editable Combobox With Both List and Inline Autocomplete Example might come closest to what browsers do with a datalist.
Once you clarified your expectations, I’m sure you’ll find a library that fits well in your environment, and respects the requirements from the pattern.

JAWS 17 doesn't read aria-label in Select box option in IE

I'm trying to add more usability to my Select box for screen reader users. Right now they have to remember the options to select the right answer. I am using aria-label to provide additional information in the 'option'. It works fine with Firefox and Chrome but not with IE 11 or less. It seems to be okay with Edge. Is there a work around or another option to get it to work in IE 11?
Code:
<option id="question1_item0">Select</option>
<option id="question1_item1" aria-label="1 an actor" >1</option>
<option id="question1_item2" aria-label="2 a country" >2</option>
<option id="question1_item3" aria-label="3 a color" >3</option>
<option id="question1_item4" aria-label="4 a wesite" >4</option>
</select>
Label is the name of an input in a form. Not every option in a select.
Can you try it like this?
<label for="actor">Actor:</label>
<select id="actor">
<option label="Select">Select</option>
<option label="1">1</option>
<option label="2">2</option>
<option label="3">3</option>
<option label="4">4</option>
</select>

use css to resize select tag in form to see all option tags

Is it possible to dynamicaly resize the visible options in select tag in forms? I have the example:
<select size="1">
<option value='1'>1
<option selected value='2'>2
<option value='3'>3
<option value='4'>4
</select>
I would like to have visible all options (to setup size dynamically with css) when design page for printing. And also to see selected option(s) in another design (color, bold ...). For resize I tried:
select{
size:4;
}
but it doesn't work. I need a working solution at least for FF, IE, Safari ...
Do have any idea?
Thanks in advance!
You can use this way:
<select size="1" size="4">
<option value='1'>1</option>
<option selected value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
</select>​​​​​​​​​​​​
And don't forget to close the </option>

Form Select List - Initially selected option not working correctly in IE

I have a form with a select list of various office locations, i have it set so it should have the office initially selected BUT it does not seem to Work in IE!!! (no surprise)
here is what i am using to preselect:
<option selected value="Office 1">Office 1</option>
here is the site: http://www.nwtaxpreparation.com/offices/122andpowell.html
let me know if you have any solutions!
HTML 4 uses:
<option value="foo" selected>Bar</option>
XHTML REQUIRES:
<option value="foo" selected="selected">Bar</option>
To say that "there is no such thing as selected="whatever" is false!
I recently had the same problem with selected options tags. I had a series of select boxes like this:
<select>
<option value="dr">Day rate</option>
<option selected="selected" value="sv">Social value</option>
</select>
<select>
<option value="dr">Day rate</option>
<option selected="selected" value="sv">Social value</option>
</select>
I couldn't work out why the correct items wouldn't select. I later discovered that it was because there was no name attribute on the select item. Firefox seems to need this to work properly, even in version 15.
<select name="type">
<option value="dr">Day rate</option>
<option selected="selected" value="sv">Social value</option>
</select>
I changed it to the above and selected="selected" works fine now.

Are Multi-line Options in Html Select Tags Possible?

Is it possible (using HTML only) to display select with options that span multiple lines each?
It is not possible using html select control.
You can use a div that can act as a dropdown list using JavaScript and css.
not only is it not possible on standard html, but it would then (as an object) become incompatible with the way IOS devices handle the option tag, which is to display a scroll list so it is not even reasonable to want the option tag to behave that way as it would break cross-device compatibility badly and unexpectedly.
as others have answered (i dont have enough reputation to upvote or comment yet) have said, it must be done with css/div styling etc and in that way is a lot more extensible with full html functionality within each of the option tag's as well as (via css styling) being mobile device friendly.
If your case is around iOS truncating long option text, then the solution from How to fix truncated text on <select> element on iOS7 can help.
Add an empty optgroup at the end of the select list:
You can implement like this:
<select>
<option selected="" disabled="">option first</option>
<option>another option that is really long and will probably be truncated on a mobile device</option>
...
<optgroup label=""></optgroup>
</select>
As the presentation of a select element is up to the user agent, I'm afraid you can't have that, unless some UA actually implements it. But select as either a ListBox or ComboBox never really had much need for items spanning multiple lines. Furthermore it would greatly confuse users as they are used to one line = one item.
No.
You could use radio buttons instead though, their <label>s can word wrap.
It would be possible by using some JavaScript with CSS styling on HTML elements, easily done with a framework like Dojo Toolkit. Otherwise, use Radio or Checkbox controls.
If you have lots of options and for that reason looking for multi-line possibility, then there is another trick that can be helpful. Instead of using select and option tag, use datalist and option tag. By this, users can search for their option inside the select area.
<input list="stocks" name="stockArea" placeholder="hello">
<label for="stockArea">Select Your Stock</label>
<datalist id="stocks">
<option value="Microsoft" >
<option value="Lenovo">
<option value="Apple">
<option value="Twitter">
<option value="Amazon">
</datalist>
What about:
<!DOCTYPE html>
<html>
<body>
<select size="13" multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
</body>
</html>
I don't know if this is what you were looking for, but maybe it could help you.
If you want to select multiple options, you must press Ctrl + click to select more options.
If you want to disable multiselect, just erase the "multiple" parameter from the SELECT tag.