bonjour,
je n'arrive pas à combiner deux fonctions.
L'une convertit "en direct" une valeur dans différentes unités,
l'autre me permet simplement d'utiliser indifféremment virgule ou point.
J'arrive à les combiner dans les <input>, avec la méthode onchange="fonction_1(this),fonction_2(this)",
mais je voudrais les combiner en amont pour alléger l'écriture (onchange="fonction_12(this)")...
voici ce que j?écris (comme bcp, je bidouille en javascript, je ne sais pas vraiment écrire)
Quelqu'un sait-il ?
------------------------------------------------
<head>
<script>function fonction_2(that){if(that.value.indexOf(",")>=0){that.value=that.value.replace(/\,/g,".");}}</script>
</head>
<body>
<script>
function round(number,X){X=(!X?15:X);return Math.round(number*Math.pow(10,X))/Math.pow(10,X);}
function fonction_1(input){
var volum=input.value*1;
var Type=input.name;
if(Type=="AA"){hl=volum/0.001;}
if(Type=="BB"){hl=volum/0.1;}
AA=round(hl*0.001);
BB=round(hl*0.1);
if(Type!="AA"){document.volumeX.km3.value=km3.toPrecision(VG);}
if(Type!="BB"){document.volumeX.m3.value=m3.toPrecision(VG);}
}
function COMBINE(that){
fonction_1(input);
fonction_2(that);}
</script>
<form id="VGF">
<input name="VG">
</form>
<form name="volumeX">
<Input name="AA" type="Text" Size="12" onchange="COMBINE(this)" >
<Input name="BB" type="Text" Size="12"onchange="COMBINE(this)" >
</form>
</body>
</html>