Range calculator


    Up to 4,000 lbs

    $.90/mile

    4,001 - 5,500

    $1.00/mile

    More than 5,501

    $1.10/mile

    Result:

    Source code for this form:

    <label>Distance:
    [number distance] miles</label>
    <label>Weight
    [number weight] lbs</label>
    
    <table>
    <tr><td>Up to 4,000 lbs</td><td>$.90/mile</td></tr>
    <tr><td>4,001 - 5,500</td><td>$1.00/mile</td></tr>
    <tr><td>More than 5,501</td><td>$1.10/mile</td></tr>
    </table>
    
    <!-- use the min:0 and max:1 trick to create hidden binary flags for each range-->
    [calculation is_more_than_4000 cf7-hide min:0 max:1 roundup "weight-4000"]
    [calculation is_more_than_5500 cf7-hide min:0 max:1 roundup "weight-5500"]
    [calculation is_less_than_4000 cf7-hide min:0 max:1 "1 - is_more_than_4000"]
    [calculation is_between_4001_and_5500 cf7-hide min:0 max:1 roundup "is_more_than_4000 - is_more_than_5500"]
    
    [calculate_button calculate_button-1 "Calculate"]
    
    Result: [calculation price precision:2 "distance * ((0.9 * is_less_than_4000) + (1 * is_between_4001_and_5500) + (1.10 * is_more_than_5500))"]