catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.77k stars 218 forks source link

Getting all country flags, country names and country codes. #395

Closed hayden664 closed 3 years ago

hayden664 commented 3 years ago

Hi, I have a contact number field in a form that I'd like to loop out all flags, country name, and country code in a dropdown and after selected, the dropdown will display the flags only.

The "With country select" is what I want to achieve, like how it is here: https://catamphetamine.gitlab.io/react-phone-number-input/.

I can only get all the country codes out at this point using getCountries(). But I can't seem to find how to loop out the flags and country names along with the country codes. Please help!

My code is available in stackoverflow. You can run the code snippet there.

catamphetamine commented 3 years ago

What?

hayden664 commented 3 years ago

I am sorry it kind of went out of format, please let me edit it for awhile

catamphetamine commented 3 years ago

It's still not clear what exactly do you want.

hayden664 commented 3 years ago

Hi so sorry for the misinterpretation. But I have edited it clearly now so that you can understand. :)

catamphetamine commented 3 years ago

Hi so sorry for the misinterpretation. But I have edited it clearly now so that you can understand. :)

Ahhh. Okay, let's start from the start:

I have a contact number field in a form that I'd like to loop out all flags, country name, and country code in a dropdown and after selected, the dropdown will display the flags only.

Can you decypher that phrase?

hayden664 commented 3 years ago

Yea sure. So it is a contact number input field with a dropdown preppended in front. In the dropdown I want to show the country flags and country names. Then after the option is selected, I want to only display the country flag there.

catamphetamine commented 3 years ago

Yea sure. So it is a contact number input field with a dropdown preppended in front. In the dropdown I want to show the country flags and country names. Then after the option is selected, I want to only display the country flag there.

Your writing is a kinda bizzarre. I won't be reading your comments here anymore. So I guess you're on your own.

hayden664 commented 3 years ago

Dropdown: image

Output: image

Please have a look at these 2 images.

hayden664 commented 3 years ago

Yea sure. So it is a contact number input field with a dropdown preppended in front. In the dropdown I want to show the country flags and country names. Then after the option is selected, I want to only display the country flag there.

Your writing is a kinda bizzarre. I won't be reading your comments here anymore. So I guess you're on your own.

I'm sorry that I caused confusion. But I would really need your help :(

catamphetamine commented 3 years ago

I'm sorry that I caused confusion.

Don't be.

But I would really need your help

Life doesn't always give us what we want. It's the cruel reality of this world.

hayden664 commented 3 years ago

I'm sorry that I caused confusion.

Don't be.

But I would really need your help

Life doesn't always give us what we want. It's the cruel reality of this world.

It just feels a bit of waste that the solution is already there in the demo but I can't implement it..