Dropdown list of countries in form element |
Dropdown list of countries in form element |
Forca |
Feb 10 2017, 12:38 AM
Post
#1
|
Member Group: Members Posts: 33 Joined: 29-April 16 Member No.: 24,203 |
Hi
I'm busy with a registration page for my clients. I'm using the form element. How do I get the dropdown list of countries? I sure do not want to create one from scratch. I'm looking for the <input> element that has this all pre-configured and I can just copy into my form element. Thanks. |
Christian J |
Feb 10 2017, 07:22 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,630 Joined: 10-August 06 Member No.: 7 |
This is usually done with a SELECT menu, not INPUT. There's no HTML element that does it automatically, but there are plenty of code examples written by others, e.g. http://www.textfixer.com/tutorials/country-dropdowns.php
|
pandy |
Feb 10 2017, 07:27 AM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
Find a list of all countries. Use your editor's Find & Replace function to get them one on each row. Use it again to replace each line break with </option>[line break character]<option>. Then fix the very first and last tags.
Or view source at a site that uses such a dropdown and steal it. |
pandy |
Feb 10 2017, 07:29 AM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
Duh. Obviously I type too slow.
|
Forca |
Feb 15 2017, 11:49 PM
Post
#5
|
Member Group: Members Posts: 33 Joined: 29-April 16 Member No.: 24,203 |
I got the list easy enough. Thank you. But can one get the <select> tag embedded inside an <input> tag so that the select tag provides all the options for that particular input? Like here, I have an input of type = "text" and name = "country". I want the country field to be populated by means of the select tag. How can this be done?
|
pandy |
Feb 16 2017, 12:50 AM
Post
#6
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
No. You can't use a form control inside another. Why do you want the text input? You can achieve the look like this.
HTML <select name="country"> <option selected disabled>Country</option> <option>Sweden</option> <option>France</option> </select> |
Forca |
Feb 16 2017, 08:29 PM
Post
#7
|
Member Group: Members Posts: 33 Joined: 29-April 16 Member No.: 24,203 |
It works real good. Thanks pandy. I've learnt that the name attribute in the select or input tag is the key. The option value attribute gets assigned to the select name attribute.
|
pandy |
Feb 16 2017, 11:36 PM
Post
#8
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
Yes, the name of SELECT is paired with the value of the selected OPTION. OPTION can't have name. Or if there is no value as in my example above, the text content is used (Sweden, France). So often a value attribute isn't necessary.
|
Forca |
Feb 17 2017, 02:58 PM
Post
#9
|
Member Group: Members Posts: 33 Joined: 29-April 16 Member No.: 24,203 |
QUOTE OPTION can't have name. Or if there is no value as in my example above, the text content is used (Sweden, France). So often a value attribute isn't necessary. I did not know that. Thanks. |
Lo-Fi Version | Time is now: 28th March 2024 - 10:49 AM |