Disable custom input in HTML input dropdown - html

Good day!
I've got a simple problem, and it involves HTML.
I've googled everywhere, but found only similar results for, "How to disable autocomplete on input".
I'm trying to find a way to block custom input for a dropdown selection input, but I can't seem to find it.
I've found the attribute disabled, and setting disabled="true" on the input completely disables it, which is not my goal.
This is my code, I found it on w3schools.com.
I've attached 2 versions of it, un-disabled and disabled.
<!--NOT DISABLED STUFF-->
<form action="/action_page.php">
<input style="margin-bottom:15vw;" list="browsers">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
</form>
<!--DISABLED STUFF-->
<form action="/action_page.php">
<input list="browsers" disabled="true">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
</form>
Thank you for reading :)

I found a way to do it, thanks to #Eisenheim's comment.
Instead of using <datalist> stuff, it works when I use <select>.
<form action="default.php">
<select>
<option value=""></option>
<option value="Internet Explorer">Internet Explorer</option>
<option value="Firefox">Firefox</option>
<option value="Chrome">Chrome</option>
<option value="Opera">Opera</option>
<option value="Safari">Safari</option>
</select>
<input type="submit">
</form>

Related

How to use select inputs with Crowd HTML for mturk

I'm trying to set up a question with a select/dropdown for answers on mechanical turk, using Crowd HTML.
This is what I've got so far, but it doesn't give me a dropdown feature when testing, and it just appears as an ordinary text input. The documentation says this:
type
Takes a string to set the HTML5 input-type behavior for the input. Examples include file and date.
So based on this I think it should work but clearly no dice. Any ideas on how to do this? Thank you
<crowd-input name="qualificationType" type="select" required>
<option value="">High School</option>
<option value="">Some College</option>
<option value="">Associate Degree</option>
<option value="">Bachelor's Degree</option>
<option value="">Professional Degree</option>
<option value="">Master's Degree</option>
<option value="">Doctorate Degree</option>
</crowd-input>
A dropdown list is a select element, which you can use in mturk. Change what you have to:
<select name="qualificationType" required>
<option value="">High School</option>
<option value="">Some College</option>
<option value="">Associate Degree</option>
<option value="">Bachelor's Degree</option>
<option value="">Professional Degree</option>
<option value="">Master's Degree</option>
<option value="">Doctorate Degree</option>
</select>
And it should work

Hide value of a search input option [duplicate]

This question already has answers here:
Setting hidden datalist option values
(4 answers)
Closed 3 years ago.
When using a search input, the list is generally from a database, where the item will have an ID and a title. To make it easier to link what text value is selected from a search input, I usually set the value as the ID, as so:
<input type="search" list="mylist">
<datalist id="mylist">
<option value="1">Example</option>
<option value="2">Test</option>
<option value="3">Another one</option>
</datalist>
But on chrome, and other browsers as far as I know, this results in the value being the "main" thing shown for the options, and the title is a sub-text underneath it.
From an end user perspective this looks awful:
Is there any way to fix this so the "id" or value isn't visible, but that's still the value used when the form is submitted?
JSFiddle
<form action="/action_page.php" method="get">
<input list="browsers" name="browser">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<input type="submit">
</form>
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>

How to hide a datalist's options using CSS

Given the following code:
<label for="myBrowser">Choose a browser from this list:</label>
<input list="browsers" id="myBrowser" name="myBrowser" />
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Internet Explorer">
<option value="Opera">
<option value="Safari">
<option value="Microsoft Edge">
</datalist>
The following UI is rendered:
What CSS can be added without changing the HTML and without using JavaScript to take away the auto-completed items so it behaves like a datalist-less input?
The following UI is desired:
It is not solved with css, but try use autocomplete="off" in your input

Is there a potential way to disable user input in a <datalist>?

I'm debating between using a <select> or <datalist> to display a drop-down list from which the user can select the items.
One downside of the <select> tag is that it's inconsistent as it renders differently in different browsers: some browsers it displays with scroll bar, and for some it's a drop-down list.
The <datalist> on the other hand seems good but I just want to know if there is any way to disable the text input where the user can type whatever they want in the text box if they don't click the down arrow button on the input field as shown:
​<form action="demo_form.asp" method="get">
<input list="browsers" name="browser">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<input type="submit">
</form>
Is there someway to disable the input bar while keeping the dropdown list? I tried the 'readonly' attribute but that renders the whole non-clickable.
You could use the pattern attribute on the input element to restrict the allowed values:
​<form action="demo_form.asp" method="get">
<input list="browsers" name="browser"
pattern="Internet Explorer|Firefox|Chrome|Opera|Safari"
title='Must be "Internet Explorer", "Firefox", "Chrome", "Opera", or "Safari"'>
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<input type="submit">
</form>

HTML <SELECT> Drop menu, show multiple but choose only one at time

Is there a way to have a select drop menu showing multiple options at ago but the user can only click on a single Item... How to restrict them from highlighting all options at ago even though they can see all the options?
Example
<form action="">
<select name="cars" multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<input type="submit">
</form>
<strong>They Should NOT Highlight or select more than one option at a go!!</strong>
I want the user to NEVER Highlight all options at ago because that will submit all options to the SERVER-SIDE Script and Err.
See it in action here:
http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select_multiple
Go to that link and try to highlight all options and Submit the query... You'll see all options are submitted. How to prevent that multiple highlighting even when they click CTRL+option after option?
Dont use multiple set a size to it
<form action="">
<select name="cars" size="4">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<input type="submit">
</form>
Demo on Fiddle
HTML:
<form action="">
<select name="cars" visible="volvo">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<input type="submit" />
</form>
From:
<select name="cars" multiple>
To:
<select name="cars">