Getting price from a price table based on X and Y
Hello,
I've been trying to calculate a price for a product based on width and height for a while but I can't figure out how to approach it.
The basics of what I need to do is having two input fields. Get the values from these and then get the price from for example an external CSV file where the input values intersects.
What I've got so far is just the basics, input fields where I get the values, and then just a simple formula based on the input values.
-
<
html
>
<
head
>
<
title
></
title
>
<
script
>
$(
document).
ready(
function() {
function
find_price() {
var
width_ep_calc =
$(
'.width_ep_calc').
val();
var
height_ep_calc =
$(
'.height_ep_calc').
val();
var
total =
width_ep_calc *
height_ep_calc;
$(
'.price_ep_calc').
text(
total);
}
$(
'.width_ep_calc, .height_ep_calc').
change(
find_price);
});
<
/
script
>
</
head
>
<
body
>
<
input
type=
"number"
class=
"width_ep_calc"
value=
""
placeholder=
"Width"
>
<
input
type=
"number"
class=
"height_ep_calc"
value=
""
placeholder=
"Height"
>
<
div
class=
"price_ep_calc"
>
</
div
>
</
body
>
</
html
>
Can anyone point me in any direction? I'm not a coder, just trying to learn :)