Create a twopart form that calculates blueberry farmers week

Create a two-part form that calculates blueberry farmer\'s weekly income from selling blueberries at the local Wichita Farmer\'s Market, based on the weight of berries sold and their cost, that can range from $3 to $8 a pound depending on the size of the berries. Use an HTML document named berries.html as a Web form with two text boxes - one for the pounds of blueberries sold and one for the price per pound. For the price you will have a drop down menu, but for the weight you will let the user type in a number. It should accept only numbers. Use a PHP document named berries.php as the form handler. If farmer sells 50lb of berries or more, the price will be time-and-a-half of what it is normally is, to make up for the special recyclable packaging.

Ensure that you comment your code appropriately. It should have all the necessary html elements.

Solution

In berries.html copy paste the given below code:

<!DOCTYPE html>
   <html>

   <head>
       <title></title>
   </head>
   <body>
       <form action=\"berries.php\" method=\"get\">
           <label>Pounds of berries to sold</label>
           <input type=\"number\" name=\"weight\">
           <label>Price per Pound</label>
           <select name=\"rate\">
               <option value=\"3\">3</option>
               <option value=\"4\">4</option>
               <option value=\"5\">5</option>
               <option value=\"6\">6</option>
               <option value=\"7\">7</option>
               <option value=\"8\">8</option>
           </select>
           <br>
           <input type=\"submit\" value=\"Submit\">
       </form>
   </body>
   </html>

In berries.php write down the given code below:

<html>
   <body>
   <?php
       $weight=$_GET[\"weight\"];
       $rate=$_GET[\"rate\"];

       if($weight>=50){
           $rate=$rate/2;
       }

       $totalPrice=$weight*$rate;
   ?>
   <h4>The total price of berries is : <?php echo $totalPrice ?></h4>
   </body>
</html>

Create a two-part form that calculates blueberry farmer\'s weekly income from selling blueberries at the local Wichita Farmer\'s Market, based on the weight of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site