<table id="items">
      <tr>
        <th>Item #</th>
        <th>Description</th>
        <th>Unit Cost</th>
        <th>Quantity</th>
        <th>Price</th>
      </tr>
      <tr>
        <td><center><input type="text" name="itemNum1" maxlength="20" size="20"/></center></td>
        <td><textarea onkeypress="return imposeMaxLength(this, 65);"></textarea></td>
        <td><input type="text" name="cost1" class="cost"/></td>        
        <td><input type="text" name="qty1" class="qty"/></td>
        <td><input type="text" name="price1" class="price1" onclick="this.value=compute20();" value=""/></td>    
      </tr>
      <tr>
        <td><center><input type="text" name="itemNum" maxlength="20" size="20"/></center></td>
        <td><textarea onkeypress="return imposeMaxLength(this, 65);"></textarea></td>
        <td><input type="text" name="cost2" class="cost"/></td>        
        <td><input type="text" name="qty2" class="qty"/></td>
        <td><input type="text" name="price2" class="price" onclick="this.value=compute1();" value=""/></td>    
      </tr>
      <tr>
        <td><center><input type="text" name="itemNum" maxlength="20" size="20"/></center></td>
        <td><textarea onkeypress="return imposeMaxLength(this, 65);"></textarea></td>
        <td><input type="text" name="cost3" class="cost"/></td>        
        <td><input type="text" name="qty3" class="qty"/></td>
        <td><input type="text" name="price3" class="price" onclick="this.value=compute2();" value=""/></td>    
      </tr>
      <tr>
        <td><center><input type="text" name="itemNum" maxlength="20" size="20"/></center></td>
        <td><textarea onkeypress="return imposeMaxLength(this, 65);"></textarea></td>
        <td><input type="text" name="cost4" class="cost"/></td>        
        <td><input type="text" name="qty4" class="qty"/></td>
        <td><input type="text" name="price4" class="price" onclick="this.value=compute3();" value=""/></td>    
      </tr>
      <tr>
        <td><center><input type="text" name="itemNum" maxlength="20" size="20"/></center></td>
        <td><textarea onkeypress="return imposeMaxLength(this, 65);"></textarea></td>
        <td><input type="text" name="cost5" class="cost"/></td>        
        <td><input type="text" name="qty5" class="qty"/></td>
        <td><input type="text" name="price5" class="price" onclick="this.value=compute4();" value=""/></td>    
      </tr>  
    </table>
    </form>
    <!-- My function to add all the prices. Is this correct? How to get prices from form s? --> 
    <?php 
	  function computeTotal(){
        import_request_variables(pg, "formval_");
		  $formval_price1;
		  $formval_price2;
		  $formval_price3;
		  $formval_price4;
		  $formval_price5;
	    //echo $formval_price1+$formval_price2+$formval_price3+$formval_price4+$formval_price5;
	      echo 1+2+3+4;
	  }
	?>
  <!-- This is where my problem is, I need to isolate the botton to get the value from my
       function that totals all the prices and stores it into a variable in the submit
       button and prints it into the total textfield.--> 
  </center>
  <div style="clear:both"></div>  
  <div id = "submit">
	<form action="<?php $_SERVER['PHP_SELF'];?>" method="post">
      <input type="submit" name="submit" value="Submit" class="btn"/>
    </form>   
  </div>   
    <table id = "beta4">
      <tr>
        <td colspan="2">Total</td>
        <td><div id="total">
          <?php
          if(isset($_POST['submit'])){
			  echo computeTotal()."Yes";  
            }           
          ?>              
        </div>
        </td>
      </tr> 
    </table>
</fieldset>
</div>
</body>
</html>

The problem is getting values from form s, textfields to the function computeTotal() and performs math operation on addition based on prices from the form s, textfields.
My code is an invoice that a user can input item number, description, quantity, item price and its price and computes for the total price with the submit button.

Any help would be much appreciated.

Thank you in advance
HotRodU2

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.