Laravel dynamic-dependant-select-box-using-jquery-ajax

Posted in CategoryLaravel
  • W
    Weblike 1 year ago

    Hi,

    I'm following the dynamic-dependant-select-box-using-jquery-ajax tutorial. I have succesfully integrated in my form for creating new records, but I have an issue on EDIT form. 

    On edit form the "Country field is populated and the State field is empty.

    Can you help please?

    Thnak you.

  • H
    Hardik Savani 1 year ago

    Thank for asking us.

    I see you following this tutorial : https://itsolutionstuff.com/post/laravel-5-dynamic-dependant-select-box-using-jquery-ajax-example-part-2example.html , i think for edit you need to pass $states variable with selected country. like this way:

     

    $countries = DB::table('countries')->pluck("name","id")->all();

    $states = DB::table('states')->where('id_country',$id_country_selected)->pluck("name","id")->all();

    return view('myform',compact('countries','states'));

     

Please login or register to leave a response.

* You May Also Like Bellow Issue to check *