Ive made a website with a booking feature. When you make a booking you specify the distance in the booking form. What I need is for the price of the booking to be calculated from the rates below:
Rates: 0-5 km $20/ mile 5-10 km $15/ mile 10-20 km $10/ mile 20-30 km $5/ mile
So if the distance was 11km, the price would be 11 x 15 = 165. This value would then need to be written to another input field in the booking form.
Doing this with PHP is beyond my skills so Im hoping to do it with jQuery. Are there any modules that do this sort of thing or can make life a bit easier? This interface is only for the site admin so js reliance and loading extra plug开发者_如何学编程 ins or libraries isn't an issue. Thanks
The jQuery Calculation plugin can be attached to form fields and do dynamic operations. For example, one of samples has four text boxes you can edit, with a fifth one immediately updating the average value of all of them.
精彩评论