Answer the question
In order to leave comments, you need to log in
How to use PHP Foreach Loop in Javascript?
Welcome all!
There is a calculator for calculating the fare using the YandexMaps API.
The cost of some routes (for example: Simferopol - Koktebel) will be calculated according to the previously set tariff. On JS somehow implemented this mechanism.
Here is a piece of code:
if ((jQuery("#from").val().indexOf("Симферополь") !== -1) && (jQuery("#to").val().indexOf("Коктебель") !== -1)) {
var curPrice = 2000;
console.log("Маршрут: Симферополь - Коктебель");
} else if ((jQuery("#to").val().indexOf("Симферополь") !== -1) && (jQuery("#from").val().indexOf("Коктебель") !== -1)) {
var curPrice = 2000;
console.log("Маршрут: Коктебель - Симферополь");
} else {
var curPrice = +(jQuery("#price" + jQuery("#class").val()).val()) * Math.floor(length);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question