Skip to content
Advertisement

Using HTML and Javascript to make a concrete supplies calculator – Takes a value of both ____m3 and a select option (mpa) to give a total price

This is my first time asking a question on Stack Overflow so apologies if I get something wrong. I am currently building a web calculator for a concrete company. Here are the details of the inputs: There is a form with the following inputs: Input 1: Cubic Meters (m3) Input 2: Strength Input 1 takes a value between 0.1 m3 and 3.2 m3. 3.2 m3 is the maximum weight that their trucks can carry. Input 2 is a select with three options = 20MPa, 25MPa, 32MPa. The difficult part is here: Depending on the strength chosen, there is a separate pricing table. For example: 0.1 m3 costs: 20MPa = $230 25MPa = $250 32MPa = $280 The prices for each list increment at different amounts per 0.1, and at different rates per table. I’ve written some if/else functions for each strength table, which checks the value range and returns the corresponding price. I have started another function to calculate the values but I can’t work out how to integrate the if else function into this calculation. I need the calculator to read the m3 (e.g. 1.4) and read the chosen option for the strength, to then find the right price in that table for that m3 amount. Sorry if my explanation isn’t well written, I’m a bit lost and would appreciate some help.

I tried to define the options by creating variables with the value of the chosen select option. I then tried to insert the result of the m3 amount + the strength variable into the calculator result box. My next step is to somehow insert my if else functions into this calculator function but I can’t work out where to put it and what syntax to use. I’ve included my HTML for the calculator, my JavaScript for the calculator function and the if else function for the price list. Gratitude for helping a Web Dev student 🙂

JavaScript
JavaScript
JavaScript

Advertisement

Answer

maybe something like that…?

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement