Help on Form

I am new to coding so please go easy on me.
I am new to coding so please go easy on me.

I am trying to add a function to this form for when it shows a negative return on investment in percent that it shows the negative sign and calculates it correctly (total dollar return divided by total proposed investment.

I would also like to have the text change on total dollar return and total percent return when they are negative.

I know there is a way to do this but it is beyond me at this point.
A link to the form is at http://www.primair-inflatables.com/roi3/

Here is the source code:

<?php $daily_impressions = $_POST["daily_impressions"]; $program_name = $_POST["program_name"]; $percent_viewers = $_POST["percent_viewers"]; $percent_interested = $_POST["percent_interested"]; $percent_might_convince = $_POST["percent_might_convince"]; $average_margin = $_POST["average_margin"]; $monthly_advertising_cost = $_POST["monthly_advertising_cost"]; if ($_POST["submit"] == "Calculate" && (empty($daily_impressions) || empty($percent_viewers) || empty($percent_interested) || empty($percent_might_convince) || empty($average_margin) || empty($monthly_advertising_cost))) { $emptyvar = 1; } if ($_POST["submit"] == "Calculate" && $emptyvar != 1) { $projected_return_percent = ((($daily_impressions)*($percent_viewers)*($percent_interested)*($percent_might_convince)*($average_margin)))/($monthly_advertising_cost/.003); $projected_return_dollars = (($daily_impressions * ($percent_viewers/100) * ($percent_interested/100) * ($percent_might_convince/100) * $average_margin) * 30)- $monthly_advertising_cost; $projected_return_percent = round($projected_return_percent, 2); $projected_return_dollars = round($projected_return_dollars, 0); } $directory = $_SERVER['PHP_SELF']; $directory = str_replace("/process.php", "", $directory); ?> Home Outdoor Media: Primair Media
<div id="form_container">
<h1 style="background-color:#336699; text-indent:-8000px"><a>ROI Calculator</a></h1>

ROI Calculator

Calculate the Return On your Investment.

    <?php if ($_POST["submit"] == "Calculate" && (empty($daily_impressions) || empty($percent_viewers) || empty($percent_interested) || empty($percent_might_convince) || empty($average_margin) || empty($monthly_advertising_cost))) { echo "

    Error: You Must fill in all numberic fields

    "; $emptyvar = 1; } ?>
  • Program Name

    Program Name

  • Daily Impressions (DEC's)

    (# of people who drive by your ad daily)

  • What % of those people do you suppose will see your ad?

    (ex: 1, 3, 5, 10)

  • Of those, what % do you think are in the market for your product?

    (ex: 1, 3, 5, 10)

  • Of those, what % do you think will decide to buy from you?

    (ex: 1, 3, 5, 10)

  • What is your average margin per sale?

    What is average margin per sale in $?

  • Monthy cost of advertising at this location?

    Monthy cost of advertising at this location?


<?php if ($emptyvar != 1 && ($projected_return_percent != 0 || $projected_return_dollars != 0)) { // ------------ Daily impressions at selected location (traffic)? ------------------ echo "According to our Department of Highways and The Traffic Audit Bureau, the daily impressions (or circulation) on the proposed board is: ", number_format($daily_impressions, 0, ',', ','),"

"; // -------------- % Viewers (How many people actually see the display)? ------------------ $results = ($daily_impressions * $percent_viewers)/100; echo "Conservatively, if you agree that just " . $percent_viewers . "% actually see your ad on this board, that means that: ", number_format($results, 0, ',', ',')," were exposed to your advertisement.

"; // ------- % Interested in your product or in the market for your -------------- $results = ($daily_impressions * $percent_viewers * $percent_interested)/10000; echo "Suppose that " . $percent_interested . "% of those people are actually in the market for your product. That's: ", number_format($results, 0, ',', ','),"

"; // ------------------- % You might convince to buy from you? ------------------------ $results = ($daily_impressions * $percent_viewers * $percent_interested * $percent_might_convince)/1000000; echo "Suppose that " . $percent_might_convince . "% of those people decide to buy from you. That's: ", number_format($results, 0, ',', ','),"

"; // -------------------- What is average margin per sale? ---------------------------- $results = ($daily_impressions * $percent_viewers * $percent_interested * $percent_might_convince * $average_margin)/1000000; echo "According to your average profit per sale of: $", number_format($average_margin, 2, '.', ',')," Your total profit per day would be: $", number_format($results, 0, '.', ','),"

"; // ------------------------------- Profit per month -------------------------------- $results = ($daily_impressions * $percent_viewers * $percent_interested * $percent_might_convince * $average_margin)*30/1000000; echo "And per month would be: $", number_format($results, 2, '.', ','),"

"; // ----------------------- Proposed Investment --------------------------------------- echo "Your proposed outdoor investment of: $", number_format($monthly_advertising_cost, 2, '.', ','),"

"; // --------------------------- Projected Returns -------------------------------- echo "Means that you would have a monthly return of: $", number_format($projected_return_dollars, 2, '.', ','),"

"; echo "Which makes your outdoor Return on Investment: " . $projected_return_percent . "%"; } ?>

One more thing, I would also like it so users can only enter numbers in the fields!

Sponsor our Newsletter | Privacy Policy | Terms of Service