2013-07-22 89 views
-5

如何將此PHP函數轉換爲使用相同算法或更好的JavaScript?paypal javascript drop drop down menu複選框

error_reporting(E_ALL^E_NOTICE); 
if($_GET['text008']=="1br") 
{ $typeservice=119; 
    if(isset($_GET['extras'])) 
    foreach ($_GET['extras'] as $k){ 
    $total +=$k; 
    } 
    echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>"; 

    echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total; 

    if(isset($_GET['freq'])) 
    { 
     if($_GET['freq']=="O") 
     { 
      echo "<br/>Once"; 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;  
     } 
     if($_GET['freq']=="M") 
     { 
      echo "<br/>Monthly";  
      $lahat = $balyo - ($balyo * .10); 
      echo "<br/>Discount:$ " . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
     if($_GET['freq']=="BW") 
     { 
      echo "<br/>Bi-Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     } 
     if($_GET['freq']=="W") 
     { 
      echo "<br/>Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
    } 

} 



if($_GET['text008']=="2br") 
{ 
    $typeservice=139; 
    if(isset($_GET['extras'])) 
    foreach ($_GET['extras'] as $k){ 
    $total +=$k; 
    } 
    echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>"; 

    echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total; 

    if(isset($_GET['freq'])) 
    { 
     if($_GET['freq']=="O") 
     { 
      echo "<br/>Once"; 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;  
     } 
     if($_GET['freq']=="M") 
     { 
      echo "<br/>Monthly";  
      $lahat = $balyo - ($balyo * .10); 
      echo "<br/>Discount:$ " . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
     if($_GET['freq']=="BW") 
     { 
      echo "<br/>Bi-Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     } 
     if($_GET['freq']=="W") 
     { 
      echo "<br/>Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
    } 

} 
if($_GET['text008']=="3br") 
{ 
    $typeservice=159; 
    if(isset($_GET['extras'])) 
    foreach ($_GET['extras'] as $k){ 
    $total +=$k; 
    } 
    echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>"; 

    echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total; 

    if(isset($_GET['freq'])) 
    { 
     if($_GET['freq']=="O") 
     { 
      echo "<br/>Once"; 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;  
     } 
     if($_GET['freq']=="M") 
     { 
      echo "<br/>Monthly";  
      $lahat = $balyo - ($balyo * .10); 
      echo "<br/>Discount:$ " . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
     if($_GET['freq']=="BW") 
     { 
      echo "<br/>Bi-Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     } 
     if($_GET['freq']=="W") 
     { 
      echo "<br/>Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
    } 

} 
if($_GET['text008']=="4br") 
{ 
    $typeservice=189; 
    if(isset($_GET['extras'])) 
    foreach ($_GET['extras'] as $k){ 
    $total +=$k; 
    } 
    echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>"; 

    echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total; 

    if(isset($_GET['freq'])) 
    { 
     if($_GET['freq']=="O") 
     { 
      echo "<br/>Once"; 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;  
     } 
     if($_GET['freq']=="M") 
     { 
      echo "<br/>Monthly";  
      $lahat = $balyo - ($balyo * .10); 
      echo "<br/>Discount:$ " . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
     if($_GET['freq']=="BW") 
     { 
      echo "<br/>Bi-Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     } 
     if($_GET['freq']=="W") 
     { 
      echo "<br/>Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
    } 

} 
if($_GET['text008']=="5br") 
{ 
    $typeservice=219; 
     if(isset($_GET['extras'])) 
    foreach ($_GET['extras'] as $k){ 
    $total +=$k; 
    } 
    echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>"; 

    echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total; 

    if(isset($_GET['freq'])) 
    { 
     if($_GET['freq']=="O") 
     { 
      echo "<br/>Once"; 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;  
     } 
     if($_GET['freq']=="M") 
     { 
      echo "<br/>Monthly";  
      $lahat = $balyo - ($balyo * .10); 
      echo "<br/>Discount:$ " . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
     if($_GET['freq']=="BW") 
     { 
      echo "<br/>Bi-Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     } 
     if($_GET['freq']=="W") 
     { 
      echo "<br/>Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
    } 

} 
if($_GET['text008']=="6br") 
{ 
    $typeservice=249; 
    if(isset($_GET['extras'])) 
    foreach ($_GET['extras'] as $k){ 
    $total +=$k; 
    } 
    echo "Service: $" . $typeservice . "<br/>" . "Extra Fees: $" .$total . "<br/>"; 

    echo "Service w/ Extra Fee: $" . $balyo=$typeservice + $total; 

    if(isset($_GET['freq'])) 
    { 
     if($_GET['freq']=="O") 
     { 
      echo "<br/>Once"; 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;  
     } 
     if($_GET['freq']=="M") 
     { 
      echo "<br/>Monthly";  
      $lahat = $balyo - ($balyo * .10); 
      echo "<br/>Discount:$ " . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
     if($_GET['freq']=="BW") 
     { 
      echo "<br/>Bi-Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     } 
     if($_GET['freq']=="W") 
     { 
      echo "<br/>Weekly"; 
      $lahat = $balyo - ($balyo * .15); 
      echo "<br/>Discount: $" . ($balyo * .15); 
      echo "<br/> Total: $" . $lahat;    
     }  
    } 
} 
+2

你知道任何的JavaScript嗎?你有什麼嘗試? – Scott

+0

嗨斯科特,即時通訊不是真正熟悉的JavaScript我需要做一個JavaScript代碼,功能相同,因爲該代碼 –

+0

歡迎來到SO,戴夫。我認爲可能是這樣,不幸的是,這個網站並不是要求其他人爲你編碼。如果你不懂JavaScript,那麼你需要學習它,或者在其他地方尋求你的解決方案。本網站只能在您對問題有所瞭解的情況下提供幫助,並嘗試自行解決。請參閱[幫助部分](http://stackoverflow.com/help)。 – Scott

回答

0

我在Facebook上回復了更新的jsFiddle,但我想我會在這裏發帖以防萬一。這是一個jsFiddle設置,在if語句中缺少大括號,並將數量設置爲整數而不是字符串。

function CalculateOrder(form) 
{ 
    //sample lang to sir ng javascript pero ito mismo na yung code. 
    //naka comment sa html ung code sa php 
    if(form.text008.value == "1br") 
    { 
     form.amount.value ="119.00"; 
    } 

    if(form.text008.value == "1br" && form.extrass.checked ==true) 
    { 
     form.amount.value = "139"; 
    } 
} 
+0

那裏是感謝斯科特! –