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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="pragma" content="no-cache" />
<title><? echo $titre_page ; ?></title>
</head>
<body>
<script language="JavaScript" src="../FormatageNombre.js"></script>
<script type="text/javascript">
function formatNumber(obj,num_devise)
{
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '-1000.247'
num.setPlaces('2', false);
if (num_devise ==1){
num.setCurrencyValue(' ');
}
else if (num_devise ==2){
num.setCurrencyValue(' $');
}
else if (num_devise ==3){
num.setCurrencyValue(' £');
}
else {
num.setCurrencyValue(' a');
}
num.setCurrency(true);
num.setCurrencyPosition(num.RIGHT_INSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ' ', ' ');
obj.value = num.toFormatted();
}
// TEST
var montant2=300;
var devise2=2;
var montant2_formate;
montant2_formate = formatNumber(montant2,devise2);
alert(montant2_formate);
//document.getElementById('montant2').value= montant2_format;
</script>
<p>
TEST
</br>
</p>
<form id='monform' name="monform" action="">
Montant 1: <input type='text' id="montant1" name='montant1' size='20' onchange='formatNumber(this,1)' value='500'><br/>
Montant 2: <input type='text' id="montant2" name='montant2' size='20' value=''><br/>
</form>
</body> |
Partager