2016-03-31 21 views
0

İki farklı vergi kullanıcı tarafından girilen bir miktar üzerinde hesaplar ve ben sorundur ve niçin hiçbir şey nerede gösterildiğine anlamıyorum toplamhesaplayın vergi ve Toplam

gösterecek bir tablo oluşturmak çalışıyorum. Komut dosyasını ekledim.

Teşekkür

<head> 

<style> 
td 
{ 
border: 1px solid black; 
padding: 20px; 
margin: 20px; 

} 
</style> 

<script type="text/javascript"> 
function calculateGST() 
{ 
var v_GST = 0.05; 
var v_price = parseFloat(Number(document.getElementById('inputuser').value)); 
var v_taxes_GST = (v_price * v_GST)); 

return v_taxes_GST; 
} 



function calculateQST() 
{ 
var v_QST = 0.09975; 
var v_price = parseFloat(Number(document.getElementById('inputuser').value)); 
    var v_taxes_QST = (v_price * v_QST)); 

    return v_taxes_QST; 

    } 

    function calculatetotal() 
    { 
    var v_prix = parseFloat(Number(document.getElementById('inputuser').value)); 
    var v_total; 

    v_total = v_price + calculateQST() + calculateGST(); 

    return v_total; 
    } 

    function showTotal() 
    { 
    document.getElementById('valueTotal').innerHTML = showTotal(); 
    } 

    function showQST() 
    { 
    document.getElementById('valueQST').innerHTML = showQST(); 
    } 


    function showGST() 
    { 
    document.getElementById('valueGST').innerHTML = calculateGST(); 
    } 

     </script> 

    </head> 
    <body> 

<table style ="width:75%"> 
<tr> 
    <td colspan=2> Example</td> 
</tr> 

<tr> 
    <td colspan=2> You sell a taxable good for $100. Taxes are calculated as follows: </td> 
    </tr> 

<tr> 
    <td> Selling price </td> 
    <td> <input type="text" id="inputuser"> </td> 
</tr> 

<tr> 
    <td> GST ($100 × 5%) </td> 
    <td> <input type="button" value="calculate GST" onclick="showGST();"/> 
<div id = "valueGST" class="GST"></div> </td> 
</tr> 

<tr> 
    <td> QST ($100 × 9.975%) </td> 
    <td> <input type="button" value="calculate QST" onclick="showQST();"/> 
<div id = "valueQST" class="QST"></div> </td> 
</tr> 

<tr> 
    <td> Total </td> 
    <td> <input type="button" value="calculate total" onclick="showTotal();"/> 
    <div id = "valueTotal" class="total"></div> </td> 
    </tr> 




    </table> 



    </body> 
    </html> 
+0

sen –

+0

https://jsfiddle.net/k34pegod/#&togetherjs=HIPDTw5snl – NewPassionnate

+0

heres hata jsfiddle.net bunu gönderin olsaydın: (endeks): 117 Yakalanmayan ReferenceError: showGST tanımlanmadı – JordanHendrix

cevap

2

Sizin showTotal() ve showQST() fonksiyonları kendilerini çağırıyor.

function showTotal() { 
    document.getElementById('valueTotal').innerHTML = calculatetotal(); 
} 

function showQST() { 
    document.getElementById('valueQST').innerHTML = calculateQST(); 
} 

function showGST() { 
    document.getElementById('valueGST').innerHTML = calculateGST(); 
}