Datalist not showing list of countries - html

Data list doesn't appear. Tried everything. I know the data list is correct.
<input name="country" list="country_name">
<datalist i="country_name">
<option value="Afghanistan">
<option value="Albania">
<option value="Algeria">
<option value="Andorra">
<option value="Armenia">
<option value="Australia">
<option value="Austria">
<option value="Azerbaijan">
<!-- etc. -->
</datalist>

It should be id
<datalist id= "country_name">

You have a typo in the id of your datalist.
i="country_name" should be id="country_name"
<input name="country" list="country_name">
<datalist id="country_name">
<option value="Afghanistan">
<option value="Albania">
<option value="Algeria">
<option value="Andorra">
<option value="Armenia">
<option value="Australia">
<option value="Austria">
<option value="Azerbaijan">
<!-- etc. -->
</datalist>

Related

How to require a selection in my select element on my signup form [duplicate]

This question already has answers here:
How do I make a field required in HTML?
(16 answers)
Closed 2 months ago.
<label for="select-choice">Birthday:</label>
<select name="select-choice" id="select-choice">
<option value="0" selected disabled>Month</option>
<option value="january">Jan</option>
<option value="february">Feb</option>
<option value="march">Mar</option>
<select name="birthday-day" id="day">
<option value="0" selected disabled>Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<select name="birthday-year" id="year">
<option value="0" selected disabled>Year</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
The Sign Up or Register page is okay but I could not validate the birthday, When I try filling it on a browser I expect it to demand or require birthday option, every other input option was demanding or requiring me to input an information but if I purposely did not fill the birthday and hit the submit button it will go through just like that, please how do I validate the birthday using HTML?
You just need to add "required" to each of your selects and then just add an empty value instead of a "0" value. When you press a button, it will detect it has no value and will automatically make the select required.
<form>
<label for="select-choice">Birthday:</label>
<select name="select-choice" id="select-choice" required>
<option value="">Month</option>
<option value="january">Jan</option>
<option value="february">Feb</option>
<option value="march">Mar</option>
</select>
<select name="birthday-day" required>
<option value="">Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<select name="birthday-year" id="year" required>
<option value="">Year</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
</select>
<button>submit</button>
</form>

Fill online form (dropdown) with python

how can I fill an online form with python (preferably with the requests library)?
On the website http://carsalesbase.com/european-car-sales-data/alfa-romeo/alfa-romeo-giulia/
there are four forms in total. Three are looking more or less identical.
I want to fill one of these three. It is a form with two dropdown menus.
<form action="http://carsalesbase.com/" class="search-form" method="get" role="search">
<input class="" id="hide-value" name="hide-value" type="hidden" value="1"/>
<select class="kelas1" id="brand-option" name="brand-option">
<option value="0">Select Brand</option>
<option value="82"> Group</option> <option value="17">Alfa Romeo</option> <option value="1">Alpina</option> <option value="249">Alpine</option> <option value="2">Aston Martin</option> <option value="67">Audi</option> <option value="68">Bentley</option> <option value="4">BMW</option> <option value="259">Borgward</option> <option value="8">Brilliance</option> <option value="69">Bugatti</option> <option value="27">Cadillac</option> <option value="75">Caterham</option> <option value="29">Chevrolet USA</option> <option value="28">Chevrolet-Daewoo</option> <option value="13">Chrysler</option> <option value="48">Citroën</option> <option value="54">Dacia</option> <option value="63">Daihatsu</option> <option value="14">Dodge</option> <option value="12">DR Motor</option> <option value="160">DS</option> <option value="18">Ferrari</option> <option value="19">Fiat</option> <option value="87">Fisker </option> <option value="24">Ford</option> <option value="33">Great Wall</option> <option value="34">Honda</option> <option value="30">Hummer</option> <option value="35">Hyundai</option> <option value="51">Infiniti</option> <option value="89">Isuzu</option> <option value="60">Jaguar</option> <option value="15">Jeep</option> <option value="36">Kia</option> <option value="3">Lada</option> <option value="70">Lamborghini</option> <option value="20">Lancia</option> <option value="23">Lancia-Chrysler</option> <option value="61">Land Rover</option> <option value="85">Landwind</option> <option value="64">Lexus</option> <option value="45">Lotus</option> <option value="83">Mahindra</option> <option value="21">Maserati</option> <option value="78">Maybach</option> <option value="40">Mazda</option> <option value="88">McLaren</option> <option value="9">Mercedes-Benz</option> <option value="41">MG</option> <option value="5">Mini</option> <option value="44">Mitsubishi</option> <option value="84">Morgan</option> <option value="52">Nissan</option> <option value="31">Opel/Vauxhall</option> <option value="47">Perodua</option> <option value="49">Peugeot</option> <option value="71">Porsche</option> <option value="46">Proton</option> <option value="91">Qoros</option> <option value="55">Renault</option> <option value="6">Rolls Royce</option> <option value="42">Rover</option> <option value="58">Saab</option> <option value="90">SAIC MG</option> <option value="72">Seat</option> <option value="73">Skoda</option> <option value="10">Smart</option> <option value="38">SSangYong</option> <option value="56">Subaru</option> <option value="57">Suzuki</option> <option value="62">Tata</option> <option value="86">Tesla</option> <option value="65">Toyota</option> <option value="74">Volkswagen</option> <option value="26">Volvo</option>
</select>
<select class="kelas1" id="model-option" name="model-option">
<option value="0">Select Model</option>
</select>
<input name="css-go" type="submit" value="Go"/>
</form>
I cannot find any good resource explaining how to do that :(
Who can help?
Thanks!
You cannot click on stuff with the requests library, but what you can do to get the data is mimic the HTTP request made after a form is submitted.
Use Chrome Network tools or Fiddler to analyze all of the requests your browser sends to the server when you submit a form. In this case, when submitting a form with the car brand as Tesla and the car model as Model X, we can see the request's method, which is of type GET, the base URL, and the required parameters.
We can use this information to simulate a webpage form submit and get the data that way:
import requests
params = {
"hide-value": 1,
"brand-option": 86,
"model-option": 2129,
"css-go": "Go"
}
html = requests.get("http://carsalesbase.com/", params=params).text
print(html)
I would use selenium, it lets you script what you would do as a user manually.
Here's a description of how to select elements on a webpage.
This answer explains how to select an option from a dropdown.

Bootstrap multiselect preselected option not working

I am using bootstrap multiselect and Select with preselected options Cheese is not working? Why?
this is my html
<div class="input-group">
<!-- input type="text" class="form-control turnusdays infofield" id="turnusdays1"-->
<!-- div class="info"></div -->
<span class="input-group-btn">
<select class="multiselectDays turnusdays" multiple="multiple">
<option value="Pon">Pon</option>
<option value="Tor">Tor</option>
<option value="Sre">Sre</option>
<option value="Čet">Čet</option>
<option value="Pet" selected>Pet</option>
<option value="Sob">Sob</option>
<option value="Ned">Ned</option>
<option value="Vikend">Vikend</option>
<option value="Praznik">Praznik</option>
</select>
</span>
</div>
What is the error you are getting ? If its MVC then use Listboxfor for multiselect.
Updated
!
Code here is :
<select multiple="multiple" style="width:500px;height:300px">
<option value="Pon" selected>Pon</option>
<option value="Tor">Tor</option>
<option value="Sre">Sre</option>
<option value="Čet">Čet</option>
<option value="Pet" selected>Pet</option>
<option value="Sob" selected>Sob</option>
<option value="Ned">Ned</option>
<option value="Vikend">Vikend</option>
<option value="Praznik">Praznik</option>
</select>
Remove the div and span class and try only the select option.

How to link page like href="#page_3" in select option in intel xdk?

<select id="byplanname" name="byplanname" style="display:none;">
<option value="Select Plan Name" multiple="multiple">Select Plan Name</option>
<option value="815" href="#page_3">815</option>
<option value="816">816</option>
<option value="816">817</option>
<option value="818">818</option>
<option value="820">820</option>
<option value="821">821</option>
<option value="822">822</option>
<option value="823">823</option>
<option value="904">904</option>
</select>
The href="#page_3" is not working ,Please tell me proper linking in intel xdk..thanx
Try something like this:
<select id="byplanname" name="byplanname" onchange="location = this.options[this.selectedIndex].value;">
<option value="google.com">815</option>
<option value="google.com">816</option>
<option value="google.com">817</option>
<option value="google.com">818</option>
<option value="google.com">820</option>
<option value="google.com">821</option>
<option value="google.com">822</option>
<option value="google.com">823</option>
<option value="google.com">904</option>
</select>
For using #page_3 you will have to put in your URL before that so it would be website.com/#page3 in the value field
JSFiddle:
http://jsfiddle.net/fqB3Z/

Do not show first option in SELECT

Is it possible to not show the first option as selected in a <select>, without adding a blank option?
<select id="location" name="location" class="form-control">
<option value="Canada">Canada</option>
<option value="France">France</option>
<option value="Germany">Germany</option>
<option value="Italy">Italy</option>
<option value="Mexico">Mexico</option>
<option value="Russia">Russia</option>
<option value="Spain">Spain</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States">United States</option>
</select>
Thanks
Steve
No.
Typically you might add something like:
<option value="0">Please select a country</option>
Then in your JS check if it's got a value of 0 before form submit.
I believe it's possible as described in here: w3schools
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" selected>Audi</option>
</select>
Example: Link