<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<title>Javacsript M2 Hesaplayıcı</title>
<style>
.test { color:red; }
#total { font-size:40px; }
h1 { margin: 0 0 10px 0; text-decoration: underline; text-align: center; }
h2 { margin: 0 0 10px 0; }
</style>
<script>
calculate = function(totalElement)
{
if (totalElement)
{
var metre ='';
var calculation = '';
var overall = '';
var fields = new Array();
var theElement = document.getElementById(totalElement);
var userInputs = myform.elements; var the_type = '';
for (var f = 0; f < userInputs.length; f++)
{
if (userInputs[f].className=='special_value')
{
if (userInputs[f].type=='select-one')
{
if (userInputs[f].options[userInputs[f].selectedIndex].value)
{
fields[f] = userInputs[f].options[userInputs[f].selectedIndex].value;
}
else
{
fields[f] = 0;
}
}
else if(userInputs[f].type=='radio' || userInputs[f].type=='checkbox')
{
if (userInputs[f].checked)
{
fields[f] = userInputs[f].value;
}
else
{
fields[f] = 0;
}
}
else
{
if (userInputs[f].value)
{
fields[f] = userInputs[f].value;
}
else
{
fields[f] = 0;
}
}
}
}
for (var i=0; i<fields.length; i++)
{
calculation += fields[i]; if (i!=fields.length-1)
{
calculation += '*';
}
}
if (calculation!='')
{
overall = eval(calculation);
}
if (overall!='')
{
theElement.innerHTML = overall;
metre = overall;
}
if (overall!='')
{
var fiyat= document.getElementById("fiyat").value;
document.myform.kdv.value = fiyat*0.08;
document.myform.toplam.value = fiyat*overall*1.08;
<!--?-->
}
}
}
</script>
</head>
<body>
<h1>Javacsript M2 Hesaplayıcı</h1>
<form name="myform">
<input onKeyPress="calculate('total');" onBlur="calculate('total');" class="special_value" type="text" name="price">
<Br/>
<input onKeyPress="calculate('total');" onBlur="calculate('total');" class="special_value" type="text" name="price2">
<Br/>
<input onKeyPress="calculate('total');" onBlur="calculate('total');" type="text" name="fiyat" id="fiyat" size="10" value="12" disabled="disabled"> Birim Fiyat<br />
<input onKeyPress="calculate('total');" onBlur="calculate('total');" type="text" name="kdv" size="10" disabled="disabled"> KDV<br />
<input onKeyPress="calculate('total');" onBlur="calculate('total');" type="text" name="toplam" size="10" disabled="disabled"> Son Fiyat<br />
<div id="total"></div>
<input onClick="calculate('total');" type="button" name="button" value="tekrar hesapla">
</form>