Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a form whereby when submitting data the user selects data from 2 dropdowns.i have a county table and towns table whereby when a user selects the county then the towns table autopoulates and the user selects his town.upon selecting the town 2 inputs are auto-selected from the towns table,the price and the pick out which are columns from the table.

here is my towns table
Python
Schema::create('towns', function (Blueprint $table) {
            $table->id();
            $table->integer('county_id');
            $table->string('town');
            $table->string('pickuppoint');
            $table->integer('shipping_charges');
            $table->timestamps();
        });


..the way i wish my code to work is to when a user selects their county they then proceed to select one of their town.upon selecting their town the pickuppoint and price automatically fills in their respective inputs in the blade file..the dropdown selects works very well but for autopopulating the pickuppoint and price doesn't work..here are my codes

the blade file

this is the code that shows the price

HTML
<td><input type="text" class="shipping_amount"></td>


here is my script

JavaScript
$(document).on('change','.town',function(){
    var tow_id=$(this).val();
    
    
    $.ajax({
        type:'get',
        url:'displayshippingprice',
        data:{'id':tow_id},
        dataType:'json',
        success:function(data){
            // console.log("shipping_charges");
            console.log(data);
            $('.pickup_point').html('');
        },
        error:function(){

        }
    });
});

how can I achieve this.

What I have tried:

i have tried debugging the script code but still the price and pickup doesn't display on the browser
Posted
Updated 18-Dec-21 1:06am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900