2017-11-08 7 views
0

注文フォーム用に2ページあり、注文詳細を処理しています。注文詳細ページは、フォームページから選択コストを計算し、合計を計算します。私は、同じページの合計を再計算する処理ページに「ヒント」選択を組み込もうとしています。フォームを使用して同じページの合計を再計算

... 
<form action="" method="post" name="tip"> 
    <select name="tip" selected="None"> 
     <option value="None"<%=tipAddNone%>>None</option> 
     <option value="10%"<%=tipAdd10%>>10%</option> 
     <option value="15%"<%=tipAdd15%>>15%</option> 
     <option value="20%"<%=tipAdd20%>>20%</option> 
    </select> 
</form> 
... 

私が作成したセッション変数によって決定された合計を計算しています:私は先端の割合を選択して、合計を再計算したいところ

です。

dim total 
session("total") = session("subtotal") + session("taxamount") 

私は先端がここで選択された場合に条件を作成しようとしました:

'Tip 
dim tipAdd10, tipAdd15, tipAdd20, tipAddNone, tip 
if request("tip") <> "None" then 
    session("tip") = request("tip") 
end if 

if request("tip") = "10%" Then 
    tip = tip * session("subtotal") 
elseif session("tip") = "15%" Then 
    tip = tip * session("subtotal") 
elseif session("tip") = "20%" Then 
    tip = tip * session("subtotal") 
elseif session("tip") = "None" Then 
    tip = 0 
end if 

私はもともと以下だった、ドロップダウンリストから、先端の割合を選択して、合計を持ってできるようにしたいと思います同じページの適用されたチップで再計算します。あなたが使用することができます

答えて

1

形で隠された要素内のすべての量を持っているし、その後はJavaScriptを介してそれらを計算し、表示するためにJavaScriptを使用..

AJAX呼び出しを呼び出し、計算に先端を使用して、同じでそれらを表示する別の方法

か、ページを掲示し、ここではその後、計算したい場合は

<form action="" method="post" name="tip"> 
<select name="tip" selected="None"> 
    <option value="0" <% if tip="0" then response.write "selected" end if %>>None</option> 
    <option value="10" <% if tip="10" then response.write "selected" end if %>>10%</option> 
    <option value="15"<% if tip="15" then response.write "selected" end if %>>15%</option> 
    <option value="20" <% if tip="20" then response.write "selected" end if %>>20%</option> 
</select> 

dim tip,tipAmount 
tip = request("tip") 
session("tip")=tip 
tipAmount= (tip * session("subtotal"))/100 
012欲しいものである下記のページ

このコードを使用して、私に教えてください。これはあなたが望むものです

関連する問題