2015-06-21 74 views
-2
<form action="" method="post"> 
Color: <input type="text" name="Color"><br> 
    ProductID: <input type="text" name="ProductID"><br> 
    <!-- Receiver Nam: <input type="text" name="last_name"><br> --> 
    Amount: <input type="text" name="Amount"><br> 
    Price: <input type="text" name="Price"><br> 
    <input type="submit" name="submit" value="Submit" class="button red"> 

</form>  

要將多個量價如何在php中的表單計算?

+1

歡迎您,請仔細閱讀[巡迴賽](http://stackoverflow.com/tour)和[如何問一個很好的問題(HTTP://計算器.com/help/how-to-ask) – RiggsFolly

+0

您需要詳細說明您的問題。它就像是有一個cliffhanger – sinusGob

回答

2
<form action="yourpage.php" method="post"> 
Color: <input type="text" name="Color"><br> 
    ProductID: <input type="text" name="ProductID"><br> 
    <!-- Receiver Nam: <input type="text" name="last_name"><br> --> 
    Amount: <input type="text" name="Amount"><br> 
    Price: <input type="text" name="Price"><br> 
    <input type="submit" name="submit" value="Submit" class="button red"> 

</form> 



<?php 

/* get the posted data */ 
$productId = $_POST['ProductID']; 
$lastName = $_POST['last_name']; 
$amount = $_POST['Amount']; 
$price = $_POST['Price']; 

$totalPrice = ($amount*$price); /*multiply the amount by the price */ 

/* print the result */ 
echo "Hi ".$lastName; 
echo "Total Price is: ".$totalPrice; 

?> 
+0

謝謝先生,對不起,即時新的但你如何在JavaScript中做到這一點? –

+1

JavaScript乘法與php相同。 –