Price lookup from table

Hi all,

I'm planning on doing a taxi booking system given the off the shelf ones are too over sized for our needs. One issue I'm having is that at the moment our Excel sheet looks up from our price file, another Excel sheet. We pick a place from list to start from a filtered drop down list, then a destination in another drop down and it fills the price automatically.

Any suggestions on implementing this in Knack please??

Sure Andy,

Check Below code 

 


$("#view_40-field_127").live("change",function(){

var from=$("#view_40-field_126").val();
var to=$("#view_40-field_127").val();;
var url='https://us-api.knack.com/v1/objects/object_21/records?page=1&rows_per_page=25&filters=%7B%22match%22%3A%22and%22%2C%22rules%22%3A%5B%7B%22field%22%3A%22field_129%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%22'+from+'%22%2C%22field_name%22%3A%22To%22%7D%2C%7B%22match%22%3A%22and%22%2C%22field%22%3A%22field_130%22%2C%22operator%22%3A%22is%22%2C%22value%22%3A%22'+to+'%22%2C%22field_name%22%3A%22From%22%7D%5D%7D&_=1533392927768';

$.ajax({
url: url,
type: 'GET',

headers: {
'X-Knack-Application-Id': API_ID, // change to your app's API info
'X-Knack-REST-API-Key': API_Key
},

success: function (response) {
if(response.records.length>=1)
{
var rcd=response.records[0];
$("#field_128").val(rcd.field_131);
}
else
{
$("#field_128").val('');
alert('Route not found.');
}
}
});

});

 

for any other professional help drop a mail

Thanks,

Sunny Singla

ssingla1985@gmail.com

Hi Sunny, have you got a script example for that please?

Hello Andy ,

 

Yes It will auto fetch price by looking into another table using jQuery 

Like below SS

Regards,

Sunny Singla

Ah tidy thanks Julian I'll have a play next week and see what I can do!

Yes, just use the From field in the Route table as the 'Display' field (in Settings). I set it up with a formula field to show both.

Hi Chaps,

Sunny, do you have any more information on using JS and API to sort this please?

Julian, I like your solution,only one thing for me is this bit:

That second box, would there be a way of making it just say Faversham? I see how it has to look up from route table however.

Thanks

Andy

Hi Andy

I think it is possible to do this using the database alone. You need a Locations Table, a Routes Table (to hold from, to and price) and a bookings table with a From and To fields - the From is a connection to Locations and To is a connection to Routes filtered by the value in the From field.

You then create an initial form which you enter the from and to into:

and a submit rule goes to a child form to add additional information and a Record rule looks up the price:

Finally you have the child form which you can edit the rest of the booking:

This is made up of a Display View to display the route and an Edit view.

Hope this helps

 

 

Hello Andy,

This can be only possible using JavaScript . 

You need to call API when both Dropdown values are fill and fetch price based upon selected locations .

 

Regards,

Sunny Singla

ssingla1985@gmail.com

+919855089359