mardi 21 décembre 2021

laravel dynamic drop down not giving value

im using ajax for laravel dropdown it was working but when i tiring to submit form it was giving id number

im getting right input in dropdown field when i try to submit page it was giving id number instead of dropdown value i what to get value of MS OFFICE AND 1000 BUT IT STORING IN DATA BASCE {COURES TYPE C_1402:} { COURSE PRICE C_1402:}

my view enter image description here

my network tab showing this id enter image description here my view page

 <div class="col-md-4">
                                        <div class="form-group">
                                            <label for="location1">Course Type  :<span class="danger">*</span> </label>
                                            <select class="custom-select form-control required" name="student_course" id="student_courses" name="location" required>
                                            <option value="">Select Course</option>
                                                @foreach ($course_name as $key => $value)
                                                    <option value=""></option>
                                                @endforeach
                                          
                                            </select>  
                                        </div>
                                    </div>

  <div class="col-md-3">
                                            <div class="form-group">
                                                <label for="videoUrl1">Course Price :</label>
                                                <select name="course_Price" id="course_Prices" class="form-control dynamic" data-dependent="course_Price">
                                                <option value=""></option>
                                                </select>
                                            </div>
                                        </div>

ajax

 <script type="text/javascript">
    $(document).ready(function() {
        $('#student_courses').on('change', function() {
            var stateID = $(this).val();
            if(stateID) {
                $.ajax({
                    url: '/Student_Course_get_price/'+stateID,
                    type: "GET",
                    dataType: "json",
                    success:function(data) {                      
                        $('#course_Prices').empty();
                        $.each(data, function(key, value) {
                        $('#course_Prices').append('<option value="'+ key +'">'+ value +'</option>');
                        });
                    }
                });
            }else{
                $('#course_Prices').empty();
            }
        });
    });
</script>

my controller

   public function Student_Course_get()
    {
        $course_name = DB::table("courses")->pluck('COURSE_NAME','COURSE_NAME_id');        
        return view('Admin/Student.Student_enrollment',compact('course_name'));
    }

    public function Student_Course_get_price($COURSE_NAME_id)
    {
        $cities = DB::table("courses")
                    ->where("C_id",$COURSE_NAME_id)
                    ->pluck('COURSE_AMOUNT','C_id');
        return json_encode($cities);
    }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3skMtYI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire