1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
| !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
<SCRIPT LANGUAGE="JavaScript">
function currencyFormat(fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true; // Enter
key = String.fromCharCode(whichCode); // Get key value from key code
if (strCheck.indexOf(key) == -1) return false; // Not a valid key
len = fld.value.length;
for(i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}
// End -->
</script>
<script type="text/javascript">
Memory = "0"; // initialise memory variable
Current = "0"; // and value of Display ("current" value)
Operation = 0; // Records code for eg * / etc.
MAXLENGTH = 30; // maximum number of digits before decimal!
function calculBien( param1, param2){
var valeur = (document.Calculator[param1].value).replace(/\s/g, ',');
valeur = (( valeur * 0.8) * 0.0725) / 0.33;
if (!isFinite( valeur)){
valeur = "Valeur trop grande";
}
if( isNaN( valeur)){
valeur = "Valeur incorrecte";
}
document.Calculator[param2].value = Math.round( valeur).toLocaleString();
}
function calculSalaire( param1, param2){
var valeur = document.Calculator[param1].value.replace(/\s/g, ',');
valeur = (((valeur/3)/0.0725)/0.8)*1;
if (!isFinite( valeur)){
valeur = "Valeur trop grande";
}
if( isNaN( valeur)){
valeur = "Valeur incorrecte";
}
document.Calculator[param2].value = Math.round( valeur).toLocaleString();
}
function FixCurrent(param) {
Current = document.Calculator[param].value;
if (Current.indexOf("NaN") != -1) {
Current = "Valeur incorrecte";
};
document.Calculator[param].value = Current;
}
</script>
</head>
<body>
<form name="Calculator">
<table width="398" id="calcul">
<tbody>
<tr>
<td width="6"> </td>
<td width="163">Salaire brut annuel:</td>
<td width="16"> </td>
<td width="193">Prix du bien:</td>
</tr>
<tr>
<td> </td>
<td> <input class="contactform" type=text name="Salaire" length=15 onKeyPress="return(currencyFormat(this,',','.',event))"></td>
<td> </td>
<td> <input class="contactform" type=text name="Bien" length=15 onKeyPress="return(currencyFormat(this,',','.',event))"></td>
</tr>
<tr>
<td> </td>
<td><input onclick="calculSalaire('Salaire', 'Bien')" name="result" type="button" value=" Calcul prix du bien " /></td>
<td> </td>
<td><input onclick="calculBien( 'Bien', 'Salaire')" name="result2" type="button" value=" Calcul du salaire " /></td>
</tr>
</tbody>
</table>
</form>
</body>
</html> |
Partager