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
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
<td><input type="text" class="shipping_amount"></td>
here is my script
$(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(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