City Country State select dropdown

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ย. 2024

ความคิดเห็น • 54

  • @mohantyagi5418
    @mohantyagi5418 ปีที่แล้ว +2

    you give perfect solution. Please improve sound quality in coming videos.

  • @firmmediaproductions
    @firmmediaproductions ปีที่แล้ว

    I want to contribute to this API, how do I get to do that, please?

  • @shivammishra3482
    @shivammishra3482 6 หลายเดือนก่อน

    Hello sir, please tell me the URL you are using.

  • @kMuhammadRayanAli
    @kMuhammadRayanAli 2 ปีที่แล้ว +1

    thanks x ♾

  • @manichandana40
    @manichandana40 2 ปีที่แล้ว +2

    hi, can we write code of this countries ,state,city dropdown in java using eclipse ?

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      In java you can use JSP or Servlet to write the code. But it's frontend stuff there you will need html and js only. For api you can me it in JSP or Servlet.

  • @SiJayDelphin
    @SiJayDelphin ปีที่แล้ว +1

    Bro you selected my country Haiti lol

  • @akshayjawale1372
    @akshayjawale1372 2 ปีที่แล้ว +1

    to get list of states by using another api in same page by using the country id ,
    is possible? if so how to do this?

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      Yes, it's possible if api has country id or name.

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว +1

      You have to use two useEffect method one with dependency and another without dependency.
      1. Call this api in useeffect which does not have dependency. 2. Make a state to save the country id or name while selecting it. 3. Make another useEffect with dependency as the country id or name which you made in last step. So that the api that you will call will trigger as the country name changes in the state. And do the filtering inside the this useEffect and save the state data in a other state.

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      If you can get me that api. I can try to give you a video solutions frd.

  • @vikrants6318
    @vikrants6318 2 ปีที่แล้ว

    Thank you Boss

  • @hanuman0320
    @hanuman0320 2 ปีที่แล้ว +1

    Hi,
    I have a problem at this line
    let states = data.filter(state=> state.country === e.target.value);
    console.log(states); ===> [ ]

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      What is the problem brother.

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      Shell we connect on Google meet.

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      Here we are filtering country name that we are getting from select box from e.target.value with whole data. So that we will get data related to that country only which will have state City etc...

    • @hanuman0320
      @hanuman0320 2 ปีที่แล้ว

      @@anuragtripathi8724 no value in states

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      @@hanuman0320 can you send me the code full code that you have written.

  • @pallimohanreddy07
    @pallimohanreddy07 3 ปีที่แล้ว +1

    👍👍👍✌✌

  • @miscany
    @miscany 2 ปีที่แล้ว +1

    Thank you so much man. How did you create the api btw?

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      No I didn't create this one. Just searched free api for country, city and state. You can easily get lots of links.

    • @miscany
      @miscany 2 ปีที่แล้ว +1

      @@anuragtripathi8724 Nice work. Gonna use it for my website.

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      @@miscany thanks

  • @AashutoshBansal
    @AashutoshBansal 2 ปีที่แล้ว +1

    hi !!
    I'm unable to fetch cities from this package
    Cn u pls help me sir

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      It's a free api, I think they would have removed the link for it. Let me check it then I can help you.

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      I have checked and they have removed the data form the link. I will find and give you new link.

    • @AashutoshBansal
      @AashutoshBansal 2 ปีที่แล้ว

      @@anuragtripathi8724 ok 😌

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      @@AashutoshBansal www.universal-tutorial.com/rest-apis/free-rest-api-for-country-state-city

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      pls use this.

  • @getHiredWithMe
    @getHiredWithMe ปีที่แล้ว

    corresponding states are not visible

    • @anuragtripathi8724
      @anuragtripathi8724  ปีที่แล้ว

      Sorry sister, the api was open source , I think they have removed the access now. I will provide you new api.

    • @anuragtripathi8724
      @anuragtripathi8724  ปีที่แล้ว

      www.universal-tutorial.com/rest-apis/free-rest-api-for-country-state-city

    • @anuragtripathi8724
      @anuragtripathi8724  ปีที่แล้ว

      You can use this one

  • @physicsfacto8414
    @physicsfacto8414 2 ปีที่แล้ว

    Hi brother can you make video for 5 level of dependent dropdowns with constant data from a file stored in the same project ?

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      Can you send me a rough sketch what you want brother.

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      Should I give you this video on Sunday. As my working hr does not permit me to do anything.

    • @physicsfacto8414
      @physicsfacto8414 2 ปีที่แล้ว

      Yeah its alright ..
      1)State dropdown 2) district dropdown 3) constituency dropdown and their description for opinion pole

  • @vijaypradipvishwakarma7191
    @vijaypradipvishwakarma7191 2 ปีที่แล้ว +1

    Plzz Share The CSS file Bro

  • @ashutoshdas5129
    @ashutoshdas5129 2 ปีที่แล้ว +1

    please share the source code

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      import axios from "axios";
      import {useEffect,useState} from "react";
      function App() {
      const [data,setData]=useState([]);
      const [state,setState]=useState([]);
      const [city,setCity]=useState([]);
      useEffect(()=>{
      axios.get("pkgstore.datahub.io/core/world-cities/world-cities_json/data/5b3dd46ad10990bca47b04b4739a02ba/world-cities_json.json").
      then(res=> setData(res.data))
      .catch(err=>console.log(err))
      },[])
      //removing duplicate country names
      let country = [...new Set(data.map(item=> item.country))];
      country.sort();
      const handleCountryChange=(e)=>{
      setState("Select State");
      setCity("Select City");
      //As you select country from select box, in below line we filter that country from all data so that we can get subcountry(state), name(city) out of it.
      let Singlecountry = data.filter(item=> item.country === e.target.value);
      //now this singleCountry which is getting the name of subcountry(state) multiple times. So to remove duplicates set is used.
      let states = [...new Set(Singlecountry.map(item=> item.subcountry))];
      //after removing the duplicate subcountry names(state names). we have saved the data in state state using setState.
      setState(states);
      }
      const handleStateChange=(e)=>{
      //here when user selects particular subcountry(state name), we have checked again with original data to get all subcounty that match that name. to get the data of perticular city.
      let singleCity = data.filter(item=> item.subcountry === e.target.value);
      setCity(singleCity);
      }
      return (
      {/*Country Selection */}
      Country:
      handleCountryChange(e)}>
      Select Country
      {country?.map((item,index)=> (
      {item}
      ))}
      {/*State Selection */}
      State:
      handleStateChange(e)}>
      Select State
      {state !=='Select State' && state?.map((item,index)=>
      {item}
      )}
      {/*City Selection */}
      City:
      Select City
      {city !=='Select City' && city?.map((item,index)=>
      {item?.name}
      )}

      );
      }
      export default App;

  • @sridharkarri127
    @sridharkarri127 2 ปีที่แล้ว +1

    can you please share this code

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว

      import axios from "axios";
      import {useEffect,useState} from "react";
      function App() {
      const [data,setData]=useState([]);
      const [state,setState]=useState([]);
      const [city,setCity]=useState([]);
      useEffect(()=>{
      axios.get("pkgstore.datahub.io/core/world-cities/world-cities_json/data/5b3dd46ad10990bca47b04b4739a02ba/world-cities_json.json").
      then(res=> setData(res.data))
      .catch(err=>console.log(err))
      },[])
      //removing duplicate country names
      let country = [...new Set(data.map(item=> item.country))];
      country.sort();
      const handleCountryChange=(e)=>{
      setState("Select State");
      setCity("Select City");
      //As you select country from select box, in below line we filter that country from all data so that we can get subcountry(state), name(city) out of it.
      let Singlecountry = data.filter(item=> item.country === e.target.value);
      //now this singleCountry which is getting the name of subcountry(state) multiple times. So to remove duplicates set is used.
      let states = [...new Set(Singlecountry.map(item=> item.subcountry))];
      //after removing the duplicate subcountry names(state names). we have saved the data in state state using setState.
      setState(states);
      }
      const handleStateChange=(e)=>{
      //here when user selects particular subcountry(state name), we have checked again with original data to get all subcounty that match that name. to get the data of perticular city.
      let singleCity = data.filter(item=> item.subcountry === e.target.value);
      setCity(singleCity);
      }
      return (
      {/*Country Selection */}
      Country:
      handleCountryChange(e)}>
      Select Country
      {country?.map((item,index)=> (
      {item}
      ))}
      {/*State Selection */}
      State:
      handleStateChange(e)}>
      Select State
      {state !=='Select State' && state?.map((item,index)=>
      {item}
      )}
      {/*City Selection */}
      City:
      Select City
      {city !=='Select City' && city?.map((item,index)=>
      {item?.name}
      )}

      );
      }
      export default App;

  • @muhammadziqrisamudra5748
    @muhammadziqrisamudra5748 2 ปีที่แล้ว

    can you shere the source code?

    • @anuragtripathi8724
      @anuragtripathi8724  2 ปีที่แล้ว +1

      import axios from "axios";
      import {useEffect,useState} from "react";
      function App() {
      const [data,setData]=useState([]);
      const [state,setState]=useState([]);
      const [city,setCity]=useState([]);
      useEffect(()=>{
      axios.get("pkgstore.datahub.io/core/world-cities/world-cities_json/data/5b3dd46ad10990bca47b04b4739a02ba/world-cities_json.json").
      then(res=> setData(res.data))
      .catch(err=>console.log(err))
      },[])
      //removing duplicate country names
      let country = [...new Set(data.map(item=> item.country))];
      country.sort();
      const handleCountryChange=(e)=>{
      setState("Select State");
      setCity("Select City");
      //As you select country from select box, in below line we filter that country from all data so that we can get subcountry(state), name(city) out of it.
      let Singlecountry = data.filter(item=> item.country === e.target.value);
      //now this singleCountry which is getting the name of subcountry(state) multiple times. So to remove duplicates set is used.
      let states = [...new Set(Singlecountry.map(item=> item.subcountry))];
      //after removing the duplicate subcountry names(state names). we have saved the data in state state using setState.
      setState(states);
      }
      const handleStateChange=(e)=>{
      //here when user selects particular subcountry(state name), we have checked again with original data to get all subcounty that match that name. to get the data of perticular city.
      let singleCity = data.filter(item=> item.subcountry === e.target.value);
      setCity(singleCity);
      }
      return (
      {/*Country Selection */}
      Country:
      handleCountryChange(e)}>
      Select Country
      {country?.map((item,index)=> (
      {item}
      ))}
      {/*State Selection */}
      State:
      handleStateChange(e)}>
      Select State
      {state !=='Select State' && state?.map((item,index)=>
      {item}
      )}
      {/*City Selection */}
      City:
      Select City
      {city !=='Select City' && city?.map((item,index)=>
      {item?.name}
      )}

      );
      }
      export default App;

  • @chandrashekharmeshram6597
    @chandrashekharmeshram6597 ปีที่แล้ว

    please share git hub repo

    • @anuragtripathi8724
      @anuragtripathi8724  ปีที่แล้ว

      import axios from "axios";
      import {useEffect,useState} from "react";
      function App() {
      const [data,setData]=useState([]);
      const [state,setState]=useState([]);
      const [city,setCity]=useState([]);
      useEffect(()=>{
      axios.get("pkgstore.datahub.io/core/world-cities/world-cities_json/data/5b3dd46ad10990bca47b04b4739a02ba/world-cities_json.json").
      then(res=> setData(res.data))
      .catch(err=>console.log(err))
      },[])
      //removing duplicate country names
      let country = [...new Set(data.map(item=> item.country))];
      country.sort();
      const handleCountryChange=(e)=>{
      setState("Select State");
      setCity("Select City");
      //As you select country from select box, in below line we filter that country from all data so that we can get subcountry(state), name(city) out of it.
      let Singlecountry = data.filter(item=> item.country === e.target.value);
      //now this singleCountry which is getting the name of subcountry(state) multiple times. So to remove duplicates set is used.
      let states = [...new Set(Singlecountry.map(item=> item.subcountry))];
      //after removing the duplicate subcountry names(state names). we have saved the data in state state using setState.
      setState(states);
      }
      const handleStateChange=(e)=>{
      //here when user selects particular subcountry(state name), we have checked again with original data to get all subcounty that match that name. to get the data of perticular city.
      let singleCity = data.filter(item=> item.subcountry === e.target.value);
      setCity(singleCity);
      }
      return (
      {/*Country Selection */}
      Country:
      handleCountryChange(e)}>
      Select Country
      {country?.map((item,index)=> (
      {item}
      ))}
      {/*State Selection */}
      State:
      handleStateChange(e)}>
      Select State
      {state !=='Select State' && state?.map((item,index)=>
      {item}
      )}
      {/*City Selection */}
      City:
      Select City
      {city !=='Select City' && city?.map((item,index)=>
      {item?.name}
      )}

      );
      }
      export default App;

  • @shivammishra3482
    @shivammishra3482 6 หลายเดือนก่อน

    Hello sir, please tell me the URL you are using.

  • @shivammishra3482
    @shivammishra3482 6 หลายเดือนก่อน

    Hello sir, please tell me the URL you are using.