Utiliser mon scipr .js plusieur fois

marlopremier Messages postés 8 Statut Membre -  
miramaze Messages postés 1429 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour,

j'ai un script nommé *.js qui me permet de faire des calculs

et il fait cela a partir d'un bouton et le résulta s'affiche

comment pourrais-je faire ce même procéder plusieurs fois avec des boutons hidden ?

voici du code pour vous aider a m'aider

la page .php

<?php
session_start();
if (!isset($_SESSION['login'])) {
header ('Location: ***.php'); exit();
}
?>
<html>
<head>

<!-- Configuration externe. -->
<link rel="stylesheet" type="text/css" href="css/index.css">

<!-- Caculer la cote -->
<script type="text/javascript" src="js/calccote.js"></script>

<title>calcul FQE</title>
<!-- ligne de code pour lire les caractères specieaux é, ê, à, ect,ect... -->
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />

<!-- script qui alterne 1 pour 0, .5 pour .5 et 0 pour 1 a chaque joueurs respectif -->
<script type="text/javascript" >
function score(j1,j2)
<!--
{
var i = document.getElementById(j1).selectedIndex;
if (i > 0) document.getElementById(j2).options[4-i].selected=true;
}
{
var i = document.getElementById(j1).selectedIndex;
if (i > 0) document.getElementById(j3).options[4-i].selected=true;
}
{
var i = document.getElementById(j1).selectedIndex;
if (i > 0) document.getElementById(j4).options[4-i].selected=true;
}
{
var i = document.getElementById(j2).selectedIndex;
if (i > 0) document.getElementById(j1).options[4-i].selected=true;
}
{
var i = document.getElementById(j2).selectedIndex;
if (i > 0) document.getElementById(j3).options[4-i].selected=true;
}
{
var i = document.getElementById(j2).selectedIndex;
if (i > 0) document.getElementById(j4).options[4-i].selected=true;
}
{
var i = document.getElementById(j3).selectedIndex;
if (i > 0) document.getElementById(j1).options[4-i].selected=true;
}
{
var i = document.getElementById(j3).selectedIndex;
if (i > 0) document.getElementById(j2).options[4-i].selected=true;
}
{
var i = document.getElementById(j3).selectedIndex;
if (i > 0) document.getElementById(j4).options[4-i].selected=true;
}
{
var i = document.getElementById(j4).selectedIndex;
if (i > 0) document.getElementById(j1).options[4-i].selected=true;
}
{
var i = document.getElementById(j4).selectedIndex;
if (i > 0) document.getElementById(j2).options[4-i].selected=true;
}
{
var i = document.getElementById(j4).selectedIndex;
if (i > 0) document.getElementById(j3).options[4-i].selected=true;
}

<!-- script pour aditionner le total d'un joueur -->
// information importante dans la fonction + le " parseFloat(parseFloat(...)+(...)); " additionne des entiers et des decimals
function calc1()
{
document.forms[0].Pts.value=parseFloat(parseFloat(document.forms[0].boite1.value)+parseFloat(document.forms[0].boite2.value)+parseFloat(document.forms[0].boite3.value));
document.forms[0].Pts1.value=parseFloat(parseFloat(document.forms[0].boite4.value)+parseFloat(document.forms[0].boite5.value)+parseFloat(document.forms[0].boite6.value));
document.forms[0].Pts2.value=parseFloat(parseFloat(document.forms[0].boite7.value)+parseFloat(document.forms[0].boite8.value)+parseFloat(document.forms[0].boite9.value));
document.forms[0].Pts3.value=parseFloat(parseFloat(document.forms[0].boite10.value)+parseFloat(document.forms[0].boite11.value)+parseFloat(document.forms[0].boite12.value));

//aditionne les victoires et defaites pour valider la valleur total
document.forms[0].totpts.value=parseFloat(parseFloat(document.forms[0].Pts.value)+parseFloat(document.forms[0].Pts1.value)+parseFloat(document.forms[0].Pts2.value)+parseFloat(document.forms[0].Pts3.value));
}

/*if (Pts=="3")

{

alert (totpts);

}
document.getElementById("bout").style.visibility= 'visible';
}function valider()
else
{
document.getElementById("bout").style.visibility= 'hidden';
}

variable1=document.formulaire.champs1.value;
variable2=document.formulaire.champs2.value;
total=parseInt(variable1)+parseInt(variable2);
alert(total);
*/
</script>

</head>

<body>

<div align="center">

<?php

require_once 'connection.php';

//$query = sprintf("SELECT id, nom, cote FROM joueurscotes WHERE id= . $_POST['nom1'] . = . $_POST['cote'] . );

// requête
$query = sprintf("SELECT id, nom, cote FROM joueurscotes
WHERE id=" . $_POST['nom1'] . "");

$query2 = sprintf("SELECT id, nom, cote FROM joueurscotes
WHERE id=" . $_POST['nom2'] . "");

$query3 = sprintf("SELECT id, nom, cote FROM joueurscotes
WHERE id=" . $_POST['nom3'] . "");

$query4 = sprintf("SELECT id, nom, cote FROM joueurscotes
WHERE id=" . $_POST['nom4'] . "");

// Exécution de la requête
$result = mysql_query($query);
$result2 = mysql_query($query2);
$result3 = mysql_query($query3);
$result4 = mysql_query($query4);

while ($row = mysql_fetch_assoc($result)) {
?>
<form method='POST' name="Form1" onSubmit="return Validator(this), return CheckData();">

<legend>Tableau d'apareillement pour quatre joueurs</legend><p>

<table border="1" cellpadding="12" cellspacing="0">
<tr>
<th>#</th>
<th>Nom</th>
<th>Cote</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>Pts</th>
<th>Nouv. cote</th>
</tr>
<?php

echo ('<tr>');
echo ('<td>1</td>');
echo ('<td>' . $row['nom'] . '</td>'); ?>
<td><input type="text" name="Orig" value=" <?php echo $row['cote']; ?>" tabindex="1" size="3" readonly></td>
<td>I</td>
<!-- *** ici ce souvenir de la facon de metre deux function dans un onchange= "" *** -->
<td><select id="partie1joueur1" name="boite1" onChange="score('partie1joueur1','partie1joueur2'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><select id="partie1joueur11" name="boite2" onChange="score('partie1joueur11','partie1joueur3'), calc1(), valider()">
<option value="0" selected></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><select name="boite3" id="partie1joueur111" onChange="score('partie1joueur111','partie1joueur4'), calc1(), valider()">
<option value="0"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><div align="center">
<input size="2" name="Pts" type="text" readonly="readonly">
</div></td>
<td><div align="center">
<input size="3" name="Nouv" type="text" readonly="readonly">
</div></td>
</tr>
<?php
}

while ($row2 = mysql_fetch_assoc($result2)) {

echo ('<tr>');
echo ('<td>2</td>');
echo ('<td>' . $row2['nom'] . '</td>'); ?>
<td><input type="text" name="C1" value=" <?php echo $row2['cote']; ?>" tabindex="1" size="3" readonly="readonly"></td>
<td><select id="partie1joueur2" name="boite4" onChange="score('partie1joueur2','partie1joueur1'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td>II</td>
<td><select id="partie1joueur22" name="boite5" onChange="score('partie1joueur22','partie1joueur33'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><select id="partie1joueur222" name="boite6" onChange="score('partie1joueur222','partie1joueur44'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><input size="2" name="Pts1" type="text" readonly="readonly"></td>
<td><div align="center">
<input size="3" name="Nouv1" type="text" readonly="readonly">
</div></td>
</tr>
<?php
}
while ($row3 = mysql_fetch_assoc($result3)) {

echo ('<tr>');
echo ('<td>3</td>');
echo ('<td>' . $row3['nom'] . '</td>'); ?>
<td><input type="text" name="C2" value=" <?php echo $row3['cote']; ?>" tabindex="1" size="3" readonly="readonly">
</td>
<td><select id="partie1joueur3" name="boite7" onChange="score('partie1joueur3','partie1joueur11'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><select id="partie1joueur33" name="boite8" onChange="score('partie1joueur33','partie1joueur22'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td>III</td>
<td><select id="partie1joueur333" name="boite9" onChange="score('partie1joueur333','partie1joueur444'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><div align="center">
<input size="2" name="Pts2" type="text" readonly="readonly">
</div></td>
<td><div align="center">
<input size="3" name="Input" type="text" readonly="readonly">
</div></td>
</tr>
<tr>
<?php
}
while ($row4 = mysql_fetch_assoc($result4)) {

echo ('<tr>');
echo ('<td>4</td>');
echo ('<td>' . $row4['nom'] . '</td>'); ?>
<td><input type="text" name="C3" value=" <?php echo $row4['cote']; ?>" tabindex="1" size="3" readonly>
</td>
<td><select id="partie1joueur4" name="boite10" onChange="score('partie1joueur4','partie1joueur111'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><select id="partie1joueur44" name="boite11" onChange="score('partie1joueur44','partie1joueur222'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td><select id="partie1joueur444" name="boite12" onChange="score('partie1joueur444','partie1joueur333'), calc1(), valider()">
<option value="0" selected="selected"></option>
<option value="1">1</option>
<option value="0.5">0.5</option>
<option value="0">0</option>
</select></td>
<td>IV</td>
<td><div align="center">
<input size="2" name="Pts3" type="text" readonly="readonly">
</div></td>
<td><div align="center">
<input size="3" name="Input" type="text" readonly="readonly">
</div></td>
</tr>
<tr>
<td colspan="7">Une section de quatre joueurs doit égaliser 6 point !</td>
<td><input size="2" name="totpts" type="text" align="right" readonly="readonly"></td>
</tr>
<tr>
<td colspan="9"><div id="bout">
<!--
<input type="button" value="Calculer la cote" onClick="Form1.Prev.value=CalculTous(Form1.Orig.value,Form1.C1.value,Form1.C2.value,Form1.C3.value);
Form1.Moy.value=CalculMoy(Form1.C1.value,Form1.C2.value,Form1.C3.value);
Form1.Perf.value=Perform(Form1.Moy.value,Form1.Pts.value);
Form1.VarCo.value=VarCote(Form1.Pts.value,Form1.Prev.value);
Form1.Boni.value=Bonis(Form1.VarCo.value);
Form1.Nouv.value=NouvC(Form1.Orig.value,Form1.VarCo.value,Form1.Boni.value); "name="B12" tabindex="12"> -->

<input type="button" value="Calculer la cote" onClick="Form1.Prev.value=CalculTous(Form1.C1.value,Form1.Orig.value,Form1.C2.value,Form1.C3.value);
Form1.Moy.value=CalculMoy(Form1.Orig.value,Form1.C2.value,Form1.C3.value);
Form1.Perf.value=Perform(Form1.Moy.value,Form1.Pts.value);
Form1.VarCo.value=VarCote(Form1.Pts.value,Form1.Prev.value);
Form1.Boni.value=Bonis(Form1.VarCo.value);
Form1.Nouv1.value=NouvC(Form1.C1.value,Form1.VarCo.value,Form1.Boni.value); ">
<input type="reset" name="reset1" value="Réinitialiser">

</div></td>
</tr>
</table>

<input type="hidden" Name="Prev" value="" size="6" tabindex="0" disabled>
<input type="hidden" Name="Perf" value="" size="6" disabled>
<input type="hidden" Name="NbP" size="6" disabled>
<input type="hidden" Name="VarCo" value="" size="6" disabled>
<input type="hidden" name="Moy" value="" size="6" disabled>
<input type="hidden" Name="Boni" value="" size="6" disabled>

<br>
<!--
<table>
<tr>
<td>Le nombre de points prévus : </td><td><input type="text" Name="Prev" value="" size="6" tabindex="0" disabled></td>
<td >Votre cote performance : </td><td><input type="text" Name="Perf" value="" size="6" disabled></td>
</tr>
<tr>
<td>Nombre de parties jouées : </td><td><input type="text" Name="NbP" size="6" disabled></td>
<td>Votre variation de cote : </td><td><input type="text" Name="VarCo" value="" size="6" disabled></td>
</tr>
<tr>
<td>

<p >La cote moyenne de vos adversaires : </td><td><input type="text" name="Moy" value="" size="6" disabled></td>
<td>Vos points bonis : </td><td><input type="text" Name="Boni" value="" size="6" disabled> </td>
</tr>
</table> -->
<p>

<!--
<input type="submit" value="Calculer la nouvelle cote" title="Base de donnée marlo.ca..." disabled="disabled">

<input type="submit" value="Valider les nouvelles cotes" title="" disabled="disabled">
-->
</form>

<?php
}

mysql_free_result($result);

?>

</div>
</body>
</html>

et le fichier .js

var NbParties;

/*-----------------------------------------------------------
On appelle la fonction CalculUn pour chaque adversaire
pour lesquels on a saisi une cote
-----------------------------------------------------------*/
function CalculTous( x2, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2 )
{
var a1,b1,c1,d1,e1,f1,g1,h1,i1,j1;
var x,a,b,c,d,e,f,g,h,i,j,res;

x = parseInt( CalculTous.arguments[0]);
a = parseInt( CalculTous.arguments[1]);
b = parseInt( CalculTous.arguments[2]);
c = parseInt( CalculTous.arguments[3]);
d = parseInt( CalculTous.arguments[4]);
e = parseInt( CalculTous.arguments[5]);
f = parseInt( CalculTous.arguments[6]);
g = parseInt( CalculTous.arguments[7]);
h = parseInt( CalculTous.arguments[8]);
i = parseInt( CalculTous.arguments[9]);
j = parseInt( CalculTous.arguments[10]);

a1 = 0; if (a > 0) a1 = CalculUn(x, a);
b1 = 0; if (b > 0) b1 = CalculUn(x, b);
c1 = 0; if (c > 0) c1 = CalculUn(x, c);
d1 = 0; if (d > 0) d1 = CalculUn(x, d);
e1 = 0; if (e > 0) e1 = CalculUn(x, e);
f1 = 0; if (f > 0) f1 = CalculUn(x, f);
g1 = 0; if (g > 0) g1 = CalculUn(x, g);
h1 = 0; if (h > 0) h1 = CalculUn(x, h);
i1 = 0; if (i > 0) i1 = CalculUn(x, i);
j1 = 0; if (j > 0) j1 = CalculUn(x, j);

res = a1 + b1 + c1 + d1 + e1 + f1 + g1 + h1 + i1 + j1;
return ( Round(res,3) );
}

/*-----------------------------------------------------------
Chaque probabilité est évaluée selon la table de la F.Q.E.
-----------------------------------------------------------*/
function CalculUn(y2, z2)
{
var x, a, r, y, z;

x = parseInt( CalculUn.arguments[0] );
a = parseInt( CalculUn.arguments[1] );

y = parseInt( CalculUn.arguments[0] );
z = parseInt( CalculUn.arguments[1] );

if (y > z)
{
a = z;
x = y;
}
else
{
a = y;
x = z;
}

if (((x - a) >= 0) && ((x - a) <= 3)) r = 0.5;
else if (((x - a) >= 4) && ((x - a) <= 10)) r = 0.51;
else if (((x - a) >= 11) && ((x - a) <= 17)) r = 0.52;
else if (((x - a) >= 18) && ((x - a) <= 25)) r = 0.53;
else if (((x - a) >= 26) && ((x - a) <= 32)) r = 0.54;
else if (((x - a) >= 33) && ((x - a) <= 39)) r = 0.55;
else if (((x - a) >= 40) && ((x - a) <= 46)) r = 0.56;
else if (((x - a) >= 47) && ((x - a) <= 53)) r = 0.57;
else if (((x - a) >= 54) && ((x - a) <= 61)) r = 0.58;
else if (((x - a) >= 62) && ((x - a) <= 68)) r = 0.59;
else if (((x - a) >= 69) && ((x - a) <= 76)) r = 0.6;
else if (((x - a) >= 77) && ((x - a) <= 83)) r = 0.61;
else if (((x - a) >= 84) && ((x - a) <= 91)) r = 0.62;
else if (((x - a) >= 92) && ((x - a) <= 98)) r = 0.63;
else if (((x - a) >= 99) && ((x - a) <= 106)) r = 0.64;
else if (((x - a) >= 107) && ((x - a) <= 113)) r = 0.65;
else if (((x - a) >= 114) && ((x - a) <= 121)) r = 0.66;
else if (((x - a) >= 122) && ((x - a) <= 129)) r = 0.67;
else if (((x - a) >= 130) && ((x - a) <= 137)) r = 0.68;
else if (((x - a) >= 138) && ((x - a) <= 145)) r = 0.69;
else if (((x - a) >= 146) && ((x - a) <= 153)) r = 0.7;
else if (((x - a) >= 154) && ((x - a) <= 162)) r = 0.71;
else if (((x - a) >= 163) && ((x - a) <= 170)) r = 0.72;
else if (((x - a) >= 171) && ((x - a) <= 179)) r = 0.73;
else if (((x - a) >= 180) && ((x - a) <= 188)) r = 0.74;
else if (((x - a) >= 189) && ((x - a) <= 197)) r = 0.75;
else if (((x - a) >= 198) && ((x - a) <= 206)) r = 0.76;
else if (((x - a) >= 207) && ((x - a) <= 215)) r = 0.77;
else if (((x - a) >= 216) && ((x - a) <= 225)) r = 0.78;
else if (((x - a) >= 226) && ((x - a) <= 235)) r = 0.79;
else if (((x - a) >= 236) && ((x - a) <= 245)) r = 0.8;
else if (((x - a) >= 246) && ((x - a) <= 256)) r = 0.81;
else if (((x - a) >= 257) && ((x - a) <= 267)) r = 0.82;
else if (((x - a) >= 268) && ((x - a) <= 278)) r = 0.83;
else if (((x - a) >= 279) && ((x - a) <= 290)) r = 0.84;
else if (((x - a) >= 291) && ((x - a) <= 302)) r = 0.85;
else if (((x - a) >= 303) && ((x - a) <= 315)) r = 0.86;
else if (((x - a) >= 316) && ((x - a) <= 328)) r = 0.87;
else if (((x - a) >= 329) && ((x - a) <= 344)) r = 0.88;
else if (((x - a) >= 345) && ((x - a) <= 357)) r = 0.89;
else if (((x - a) >= 358) && ((x - a) <= 374)) r = 0.9;
else if (((x - a) >= 375) && ((x - a) <= 391)) r = 0.91;
else if (((x - a) >= 392) && ((x - a) <= 411)) r = 0.92;
else if (((x - a) >= 312) && ((x - a) <= 432)) r = 0.93;
else if (((x - a) >= 433) && ((x - a) <= 456)) r = 0.94;
else if (((x - a) >= 457) && ((x - a) <= 484)) r = 0.95;
else if (((x - a) >= 485) && ((x - a) <= 517)) r = 0.96;
else if (((x - a) >= 518) && ((x - a) <= 559)) r = 0.97;
else if (((x - a) >= 560) && ((x - a) <= 619)) r = 0.98;
else if (((x - a) >= 620) && ((x - a) <= 734)) r = 0.99;
else if ((x - a) >= 735) r = 1;

if (z > y)
r = 1 - r;
if (z = 0)
r = 0;
return r;
}

/*-----------------------------------------------------------
Chaque probabilité est évaluée selon la table de la F.Q.E.
-----------------------------------------------------------*/
function CalculMoy( a2, b2, c2, d2, e2, f2, g2, h2, i2, j2 )
{
var a,b,c,d,e,f,g,h,i,j,avrg;

avrg = 0;
nb = 0;

a = parseInt( CalculMoy.arguments[0]);
b = parseInt( CalculMoy.arguments[1]);
c = parseInt( CalculMoy.arguments[2]);
d = parseInt( CalculMoy.arguments[3]);
e = parseInt( CalculMoy.arguments[4]);
f = parseInt( CalculMoy.arguments[5]);
g = parseInt( CalculMoy.arguments[6]);
h = parseInt( CalculMoy.arguments[7]);
i = parseInt( CalculMoy.arguments[8]);
j = parseInt( CalculMoy.arguments[9]);

if (a > 0) nb++;
if (b > 0) nb++;
if (c > 0) nb++;
if (d > 0) nb++;
if (e > 0) nb++;
if (f > 0) nb++;
if (g > 0) nb++;
if (h > 0) nb++;
if (i > 0) nb++;
if (j > 0) nb++;

NbParties = nb;

Form1.NbP.value= NbParties;

avrg = ( a + b + c + d + e + f + g + h + i + j) / nb;
return ( RoundSup(avrg,0) );

}
/*-----------------------------------------------------------
Calculer la performance
-----------------------------------------------------------*/
function Perform (m2,p2)
{
var moyenne, points, res;

moyenne = parseInt( Perform.arguments[0]);
points = Perform.arguments[1];

res = (moyenne + (400 * ((points - (NbParties - points))/ NbParties)));

res = RoundSup(res,1);

return( res );
}

/*-----------------------------------------------------------
Calculer la variation de cote
-----------------------------------------------------------*/
function VarCote(p1, p2)
{
var Pts, Prev, res;

Pts = VarCote.arguments[0];
Prev= VarCote.arguments[1];

if ((Pts - Prev) < 0)
res = RoundInf(32*(Pts-Prev));
else
res = RoundSup(32*(Pts-Prev));

return res;
}
/*-----------------------------------------------------------
Calculer les points Bonis
-----------------------------------------------------------*/
function Bonis(p1)
{
var VarC, MinBonis, res;

VarC= Bonis.arguments[0];

if (NbParties < 4) MinBonis = 0;
else if (NbParties == 4) MinBonis = 24;
else if (NbParties == 5) MinBonis = 26;
else if (NbParties == 6) MinBonis = 28;
else if (NbParties == 7) MinBonis = 30;
else if (NbParties == 8) MinBonis = 32;
else if (NbParties == 9) MinBonis = 34;
else if (NbParties == 10) MinBonis = 36;

if ((VarC > MinBonis) && (NbParties > 3))
res = RoundSup(VarC - MinBonis);
else
res = 0;

return res;
}
/*-----------------------------------------------------------
Calculer la nouvelle cote
-----------------------------------------------------------*/
function NouvC(p1,p2,p3)
{
var VarC, Bonis, Orig, res;

Orig = parseInt( NouvC.arguments[0]);
VarC = parseInt( NouvC.arguments[1]);
Bonis = parseInt( NouvC.arguments[2]);

res = Orig + VarC + Bonis;

return res;
}
/*-----------------------------------------------------------
Arrondir à n décimales
-----------------------------------------------------------*/
function Round (n,p)
{
n = Math.round(n * 100) / 100;
n = (n + 0.001) + '';
return n.substring(0, n.indexOf('.') + p);
}

/*-----------------------------------------------------------
Arrondir à l'entier supérieur
-----------------------------------------------------------*/
function RoundSup (n)
{
var t, res;

t = Math.round(n);
if (t < n)
res = t + 0;
else
if (t > n)
res = t;
else
res = t;

return res;
}
/*-----------------------------------------------------------
Arrondir à l'entier inférieur
-----------------------------------------------------------*/
function RoundInf (n)
{
var t, res;

t = Math.round(n);
if (t < n)
res = t + 0;
else
if (t > n)
res = t;
else
res = t;

return res;
}

mon script doit me donner de nouvelle variable diferante pour aficher dans les chan<mp respectif

merci !

4 réponses

  1. miramaze Messages postés 1429 Date d'inscription   Statut Contributeur Dernière intervention   92
     
    Salut,
    je ne voudrais pas critiquer (bien que c'est ce que je vais faire et je m'en excuse) mais il n'est pas un tantinet compliqué ton code ? Sans avoir regardé exactement dans le détail ce que tu as fais, à vu de nez, je pense que tu as largement moyen de refactorer ça.

    Mais ce n'est pas la question, je m'égare, que veux-tu faire exactement ? Peux-tu me dire précisement ce qu'est censé faire ce bout de code et le résultat que tu veux obtenir ?

    All software sucks.
    Alan Cox
    0
  2. marlopremier Messages postés 8 Statut Membre
     
    Bonsoir miramaze

    merci d'essayer de m'aider

    j'essaye de faire un module pour compté la cote de quatre joueurs d'échecs

    je te donnerai bien le lien sur mon serveur pour que tu vois ce que j'ai fais

    mais il faut un mot de passe ... avez vous une suggestion

    au pire voici mon adresse marlopremier@yahoo.fr

    écris moi et je te montrerai

    je vais metre tous le code ici

    -- resulta.php --

    <?php
    session_start();
    if (!isset($_SESSION['login'])) {
    header ('Location: .php'); exit();
    }
    ?>
    <html>
    <head>

    <!-- Configuration externe. -->
    <link rel="stylesheet" type="text/css" href="css/index.css">

    <!-- Caculer la cote -->
    <script type="text/javascript" src="js/calccote.js"></script>

    <title>calcul FQE</title>
    <!-- ligne de code pour lire les caractères specieaux é, ê, à, ect,ect... -->
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />

    <!-- script qui alterne 1 pour 0, .5 pour .5 et 0 pour 1 a chaque joueurs respectif -->
    <script type="text/javascript" >
    function score(j1,j2)
    <!--
    {
    var i = document.getElementById(j1).selectedIndex;
    if (i > 0) document.getElementById(j2).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j1).selectedIndex;
    if (i > 0) document.getElementById(j3).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j1).selectedIndex;
    if (i > 0) document.getElementById(j4).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j2).selectedIndex;
    if (i > 0) document.getElementById(j1).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j2).selectedIndex;
    if (i > 0) document.getElementById(j3).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j2).selectedIndex;
    if (i > 0) document.getElementById(j4).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j3).selectedIndex;
    if (i > 0) document.getElementById(j1).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j3).selectedIndex;
    if (i > 0) document.getElementById(j2).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j3).selectedIndex;
    if (i > 0) document.getElementById(j4).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j4).selectedIndex;
    if (i > 0) document.getElementById(j1).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j4).selectedIndex;
    if (i > 0) document.getElementById(j2).options[4-i].selected=true;
    }
    {
    var i = document.getElementById(j4).selectedIndex;
    if (i > 0) document.getElementById(j3).options[4-i].selected=true;
    }

    <!-- script pour aditionner le total d'un joueur -->
    // information importante dans la fonction + le " parseFloat(parseFloat(...)+(...)); " additionne des entiers et des decimals
    function calc1()
    {
    document.forms[0].Pts.value=parseFloat(parseFloat(document.forms[0].boite1.value)+parseFloat(document.forms[0].boite2.value)+parseFloat(document.forms[0].boite3.value));
    document.forms[0].Pts1.value=parseFloat(parseFloat(document.forms[0].boite4.value)+parseFloat(document.forms[0].boite5.value)+parseFloat(document.forms[0].boite6.value));
    document.forms[0].Pts2.value=parseFloat(parseFloat(document.forms[0].boite7.value)+parseFloat(document.forms[0].boite8.value)+parseFloat(document.forms[0].boite9.value));
    document.forms[0].Pts3.value=parseFloat(parseFloat(document.forms[0].boite10.value)+parseFloat(document.forms[0].boite11.value)+parseFloat(document.forms[0].boite12.value));

    //aditionne les victoires et defaites pour valider la valleur total
    document.forms[0].totpts.value=parseFloat(parseFloat(document.forms[0].Pts.value)+parseFloat(document.forms[0].Pts1.value)+parseFloat(document.forms[0].Pts2.value)+parseFloat(document.forms[0].Pts3.value));
    }

    </script>

    </head>

    <body>

    <div align="center">

    <?php

    require_once 'contactmysql.php';

    //$query = sprintf("SELECT id, nom, cote FROM joueurscotes WHERE id= . $_POST['nom1'] . = . $_POST['cote'] . );

    // requête
    $query = sprintf("SELECT id, nom, cote FROM joueurscotes
    WHERE id=" . $_POST['nom1'] . "");

    $query2 = sprintf("SELECT id, nom, cote FROM joueurscotes
    WHERE id=" . $_POST['nom2'] . "");

    $query3 = sprintf("SELECT id, nom, cote FROM joueurscotes
    WHERE id=" . $_POST['nom3'] . "");

    $query4 = sprintf("SELECT id, nom, cote FROM joueurscotes
    WHERE id=" . $_POST['nom4'] . "");

    // Exécution de la requête
    $result = mysql_query($query);
    $result2 = mysql_query($query2);
    $result3 = mysql_query($query3);
    $result4 = mysql_query($query4);

    while ($row = mysql_fetch_assoc($result)) {
    ?>
    <form method='POST' name="Form1" onSubmit="return Validator(this), return CheckData();">

    <legend>Tableau d'apareillement pour quatre joueurs</legend><p>

    <table border="1" cellpadding="12" cellspacing="0">
    <tr>
    <th>#</th>
    <th>Nom</th>
    <th>Cote</th>
    <th>1</th>
    <th>2</th>
    <th>3</th>
    <th>4</th>
    <th>Pts</th>
    <th>Nouv. cote</th>
    </tr>
    <?php

    echo ('<tr>');
    echo ('<td>1</td>');
    echo ('<td>' . $row['nom'] . '</td>'); ?>
    <td><input type="text" name="Orig" value=" <?php echo $row['cote']; ?>" tabindex="1" size="3" readonly></td>
    <td>I</td>
    <!-- *** ici ce souvenir de la facon de metre deux function dans un onchange= "" *** -->
    <td><select id="partie1joueur1" name="boite1" onChange="score('partie1joueur1','partie1joueur2'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><select id="partie1joueur11" name="boite2" onChange="score('partie1joueur11','partie1joueur3'), calc1(), valider()">
    <option value="0" selected></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><select name="boite3" id="partie1joueur111" onChange="score('partie1joueur111','partie1joueur4'), calc1(), valider()">
    <option value="0"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><div align="center">
    <input size="2" name="Pts" type="text" readonly="readonly">
    </div></td>
    <td><div align="center">
    <input size="3" name="Nouv" type="text" readonly="readonly">
    </div></td>
    </tr>
    <?php
    }

    while ($row2 = mysql_fetch_assoc($result2)) {

    echo ('<tr>');
    echo ('<td>2</td>');
    echo ('<td>' . $row2['nom'] . '</td>'); ?>
    <td><input type="text" name="C1" value=" <?php echo $row2['cote']; ?>" tabindex="1" size="3" readonly="readonly"></td>
    <td><select id="partie1joueur2" name="boite4" onChange="score('partie1joueur2','partie1joueur1'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td>II</td>
    <td><select id="partie1joueur22" name="boite5" onChange="score('partie1joueur22','partie1joueur33'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><select id="partie1joueur222" name="boite6" onChange="score('partie1joueur222','partie1joueur44'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><input size="2" name="Pts1" type="text" readonly="readonly"></td>
    <td><div align="center">
    <input size="3" name="Nouv1" type="text" readonly="readonly">
    </div></td>
    </tr>
    <?php
    }
    while ($row3 = mysql_fetch_assoc($result3)) {

    echo ('<tr>');
    echo ('<td>3</td>');
    echo ('<td>' . $row3['nom'] . '</td>'); ?>
    <td><input type="text" name="C2" value=" <?php echo $row3['cote']; ?>" tabindex="1" size="3" readonly="readonly">
    </td>
    <td><select id="partie1joueur3" name="boite7" onChange="score('partie1joueur3','partie1joueur11'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><select id="partie1joueur33" name="boite8" onChange="score('partie1joueur33','partie1joueur22'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td>III</td>
    <td><select id="partie1joueur333" name="boite9" onChange="score('partie1joueur333','partie1joueur444'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><div align="center">
    <input size="2" name="Pts2" type="text" readonly="readonly">
    </div></td>
    <td><div align="center">
    <input size="3" name="Input" type="text" readonly="readonly">
    </div></td>
    </tr>
    <tr>
    <?php
    }
    while ($row4 = mysql_fetch_assoc($result4)) {

    echo ('<tr>');
    echo ('<td>4</td>');
    echo ('<td>' . $row4['nom'] . '</td>'); ?>
    <td><input type="text" name="C3" value=" <?php echo $row4['cote']; ?>" tabindex="1" size="3" readonly>
    </td>
    <td><select id="partie1joueur4" name="boite10" onChange="score('partie1joueur4','partie1joueur111'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><select id="partie1joueur44" name="boite11" onChange="score('partie1joueur44','partie1joueur222'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td><select id="partie1joueur444" name="boite12" onChange="score('partie1joueur444','partie1joueur333'), calc1(), valider()">
    <option value="0" selected="selected"></option>
    <option value="1">1</option>
    <option value="0.5">0.5</option>
    <option value="0">0</option>
    </select></td>
    <td>IV</td>
    <td><div align="center">
    <input size="2" name="Pts3" type="text" readonly="readonly">
    </div></td>
    <td><div align="center">
    <input size="3" name="Input" type="text" readonly="readonly">
    </div></td>
    </tr>
    <tr>
    <td colspan="7">Une section de quatre joueurs doit égaliser 6 point !</td>
    <td><input size="2" name="totpts" type="text" align="right" readonly="readonly"></td>
    </tr>
    <tr>
    <td colspan="9"><div id="bout">

    <input type="button" value="Calculer la cote" onClick="Form1.Prev.value=CalculTous(Form1.Orig.value,Form1.C1.value,Form1.C2.value,Form1.C3.value);
    Form1.Moy.value=CalculMoy(Form1.C1.value,Form1.C2.value,Form1.C3.value);
    Form1.Perf.value=Perform(Form1.Moy.value,Form1.Pts.value);
    Form1.VarCo.value=VarCote(Form1.Pts.value,Form1.Prev.value);
    Form1.Boni.value=Bonis(Form1.VarCo.value);
    Form1.Nouv.value=NouvC(Form1.Orig.value,Form1.VarCo.value,Form1.Boni.value); "name="B12" tabindex="12">

    bouton hidden qui ne fonctionne pas
    <input type="button" value="Calculer la cote" onClick="Form1.Prev.value=CalculTous(Form1.C1.value,Form1.Orig.value,Form1.C2.value,Form1.C3.value);
    Form1.Moy.value=CalculMoy(Form1.Orig.value,Form1.C2.value,Form1.C3.value);
    Form1.Perf.value=Perform(Form1.Moy.value,Form1.Pts.value);
    Form1.VarCo.value=VarCote(Form1.Pts.value,Form1.Prev.value);
    Form1.Boni.value=Bonis(Form1.VarCo.value);
    Form1.Nouv1.value=NouvC(Form1.C1.value,Form1.VarCo.value,Form1.Boni.value); ">
    <input type="reset" name="reset1" value="Réinitialiser">

    </div></td>
    </tr>
    </table>

    <input type="hidden" Name="Prev" value="" size="6" tabindex="0" disabled>
    <input type="hidden" Name="Perf" value="" size="6" disabled>
    <input type="hidden" Name="NbP" size="6" disabled>
    <input type="hidden" Name="VarCo" value="" size="6" disabled>
    <input type="hidden" name="Moy" value="" size="6" disabled>
    <input type="hidden" Name="Boni" value="" size="6" disabled>

    <br>
    <!--
    <table>
    <tr>
    <td>Le nombre de points prévus : </td><td><input type="text" Name="Prev" value="" size="6" tabindex="0" disabled></td>
    <td >Votre cote performance : </td><td><input type="text" Name="Perf" value="" size="6" disabled></td>
    </tr>
    <tr>
    <td>Nombre de parties jouées : </td><td><input type="text" Name="NbP" size="6" disabled></td>
    <td>Votre variation de cote : </td><td><input type="text" Name="VarCo" value="" size="6" disabled></td>
    </tr>
    <tr>
    <td>

    <p >La cote moyenne de vos adversaires : </td><td><input type="text" name="Moy" value="" size="6" disabled></td>
    <td>Vos points bonis : </td><td><input type="text" Name="Boni" value="" size="6" disabled> </td>
    </tr>
    </table> -->
    <p>

    </form>

    <?php
    }

    mysql_free_result($result);

    ?>

    </div>
    </body>
    </html>

    cette page reçois de la précédente quatre nom et une cote pour chacun

    mon sript java fait une moyenne avec les trois cotes des joueurs adverses
    et cette moy. est utilise pour trouver la nouvelle cote...

    je voudrait que trois autre bouton hidden utilise ce mémé script pour éditionner la cote des trois autres

    mon script fonctionne bien pour le premier input bouton

    mais j'ai un problème de variable dans mon script pour le retour dans le champs qui est différant pour chaque calcul (3 autres )... j'espère être plus clair

    voici le script java mais pour t'aider a comprendre

    voici la formule FQE ou FIDE...

    cote = ca+32*(r-rp)

    ca = ancienne cote
    r = nombre de victoire
    rp = différence des cotes des trois joueurs celons le
    tableau elo ( CalculUn )du code java

    voici le code java

    js/calccote.js

    var NbParties;

    /*-----------------------------------------------------------
    On appelle la fonction CalculUn pour chaque adversaire
    pour lesquels on a saisi une cote
    -----------------------------------------------------------*/
    function CalculTous( x2, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2 )
    {
    var a1,b1,c1,d1,e1,f1,g1,h1,i1,j1;
    var x,a,b,c,d,e,f,g,h,i,j,res;

    x = parseInt( CalculTous.arguments[0]);
    a = parseInt( CalculTous.arguments[1]);
    b = parseInt( CalculTous.arguments[2]);
    c = parseInt( CalculTous.arguments[3]);
    d = parseInt( CalculTous.arguments[4]);
    e = parseInt( CalculTous.arguments[5]);
    f = parseInt( CalculTous.arguments[6]);
    g = parseInt( CalculTous.arguments[7]);
    h = parseInt( CalculTous.arguments[8]);
    i = parseInt( CalculTous.arguments[9]);
    j = parseInt( CalculTous.arguments[10]);

    a1 = 0; if (a > 0) a1 = CalculUn(x, a);
    b1 = 0; if (b > 0) b1 = CalculUn(x, b);
    c1 = 0; if (c > 0) c1 = CalculUn(x, c);
    d1 = 0; if (d > 0) d1 = CalculUn(x, d);
    e1 = 0; if (e > 0) e1 = CalculUn(x, e);
    f1 = 0; if (f > 0) f1 = CalculUn(x, f);
    g1 = 0; if (g > 0) g1 = CalculUn(x, g);
    h1 = 0; if (h > 0) h1 = CalculUn(x, h);
    i1 = 0; if (i > 0) i1 = CalculUn(x, i);
    j1 = 0; if (j > 0) j1 = CalculUn(x, j);

    res = a1 + b1 + c1 + d1 + e1 + f1 + g1 + h1 + i1 + j1;
    return ( Round(res,3) );
    }

    /*-----------------------------------------------------------
    Chaque probabilité est évaluée selon la table de la F.Q.E.
    -----------------------------------------------------------*/
    function CalculUn(y2, z2)
    {
    var x, a, r, y, z;

    x = parseInt( CalculUn.arguments[0] );
    a = parseInt( CalculUn.arguments[1] );

    y = parseInt( CalculUn.arguments[0] );
    z = parseInt( CalculUn.arguments[1] );

    if (y > z)
    {
    a = z;
    x = y;
    }
    else
    {
    a = y;
    x = z;
    }

    if (((x - a) >= 0) && ((x - a) <= 3)) r = 0.5;
    else if (((x - a) >= 4) && ((x - a) <= 10)) r = 0.51;
    else if (((x - a) >= 11) && ((x - a) <= 17)) r = 0.52;
    else if (((x - a) >= 18) && ((x - a) <= 25)) r = 0.53;
    else if (((x - a) >= 26) && ((x - a) <= 32)) r = 0.54;
    else if (((x - a) >= 33) && ((x - a) <= 39)) r = 0.55;
    else if (((x - a) >= 40) && ((x - a) <= 46)) r = 0.56;
    else if (((x - a) >= 47) && ((x - a) <= 53)) r = 0.57;
    else if (((x - a) >= 54) && ((x - a) <= 61)) r = 0.58;
    else if (((x - a) >= 62) && ((x - a) <= 68)) r = 0.59;
    else if (((x - a) >= 69) && ((x - a) <= 76)) r = 0.6;
    else if (((x - a) >= 77) && ((x - a) <= 83)) r = 0.61;
    else if (((x - a) >= 84) && ((x - a) <= 91)) r = 0.62;
    else if (((x - a) >= 92) && ((x - a) <= 98)) r = 0.63;
    else if (((x - a) >= 99) && ((x - a) <= 106)) r = 0.64;
    else if (((x - a) >= 107) && ((x - a) <= 113)) r = 0.65;
    else if (((x - a) >= 114) && ((x - a) <= 121)) r = 0.66;
    else if (((x - a) >= 122) && ((x - a) <= 129)) r = 0.67;
    else if (((x - a) >= 130) && ((x - a) <= 137)) r = 0.68;
    else if (((x - a) >= 138) && ((x - a) <= 145)) r = 0.69;
    else if (((x - a) >= 146) && ((x - a) <= 153)) r = 0.7;
    else if (((x - a) >= 154) && ((x - a) <= 162)) r = 0.71;
    else if (((x - a) >= 163) && ((x - a) <= 170)) r = 0.72;
    else if (((x - a) >= 171) && ((x - a) <= 179)) r = 0.73;
    else if (((x - a) >= 180) && ((x - a) <= 188)) r = 0.74;
    else if (((x - a) >= 189) && ((x - a) <= 197)) r = 0.75;
    else if (((x - a) >= 198) && ((x - a) <= 206)) r = 0.76;
    else if (((x - a) >= 207) && ((x - a) <= 215)) r = 0.77;
    else if (((x - a) >= 216) && ((x - a) <= 225)) r = 0.78;
    else if (((x - a) >= 226) && ((x - a) <= 235)) r = 0.79;
    else if (((x - a) >= 236) && ((x - a) <= 245)) r = 0.8;
    else if (((x - a) >= 246) && ((x - a) <= 256)) r = 0.81;
    else if (((x - a) >= 257) && ((x - a) <= 267)) r = 0.82;
    else if (((x - a) >= 268) && ((x - a) <= 278)) r = 0.83;
    else if (((x - a) >= 279) && ((x - a) <= 290)) r = 0.84;
    else if (((x - a) >= 291) && ((x - a) <= 302)) r = 0.85;
    else if (((x - a) >= 303) && ((x - a) <= 315)) r = 0.86;
    else if (((x - a) >= 316) && ((x - a) <= 328)) r = 0.87;
    else if (((x - a) >= 329) && ((x - a) <= 344)) r = 0.88;
    else if (((x - a) >= 345) && ((x - a) <= 357)) r = 0.89;
    else if (((x - a) >= 358) && ((x - a) <= 374)) r = 0.9;
    else if (((x - a) >= 375) && ((x - a) <= 391)) r = 0.91;
    else if (((x - a) >= 392) && ((x - a) <= 411)) r = 0.92;
    else if (((x - a) >= 312) && ((x - a) <= 432)) r = 0.93;
    else if (((x - a) >= 433) && ((x - a) <= 456)) r = 0.94;
    else if (((x - a) >= 457) && ((x - a) <= 484)) r = 0.95;
    else if (((x - a) >= 485) && ((x - a) <= 517)) r = 0.96;
    else if (((x - a) >= 518) && ((x - a) <= 559)) r = 0.97;
    else if (((x - a) >= 560) && ((x - a) <= 619)) r = 0.98;
    else if (((x - a) >= 620) && ((x - a) <= 734)) r = 0.99;
    else if ((x - a) >= 735) r = 1;

    if (z > y)
    r = 1 - r;
    if (z = 0)
    r = 0;
    return r;
    }

    /*-----------------------------------------------------------
    Chaque probabilité est évaluée selon la table de la F.Q.E.
    -----------------------------------------------------------*/
    function CalculMoy( a2, b2, c2, d2, e2, f2, g2, h2, i2, j2 )
    {
    var a,b,c,d,e,f,g,h,i,j,avrg;

    avrg = 0;
    nb = 0;

    a = parseInt( CalculMoy.arguments[0]);
    b = parseInt( CalculMoy.arguments[1]);
    c = parseInt( CalculMoy.arguments[2]);
    d = parseInt( CalculMoy.arguments[3]);
    e = parseInt( CalculMoy.arguments[4]);
    f = parseInt( CalculMoy.arguments[5]);
    g = parseInt( CalculMoy.arguments[6]);
    h = parseInt( CalculMoy.arguments[7]);
    i = parseInt( CalculMoy.arguments[8]);
    j = parseInt( CalculMoy.arguments[9]);

    if (a > 0) nb++;
    if (b > 0) nb++;
    if (c > 0) nb++;
    if (d > 0) nb++;
    if (e > 0) nb++;
    if (f > 0) nb++;
    if (g > 0) nb++;
    if (h > 0) nb++;
    if (i > 0) nb++;
    if (j > 0) nb++;

    NbParties = nb;

    Form1.NbP.value= NbParties;

    avrg = ( a + b + c + d + e + f + g + h + i + j) / nb;
    return ( RoundSup(avrg,0) );

    }
    /*-----------------------------------------------------------
    Calculer la performance
    -----------------------------------------------------------*/
    function Perform (m2,p2)
    {
    var moyenne, points, res;

    moyenne = parseInt( Perform.arguments[0]);
    points = Perform.arguments[1];

    res = (moyenne + (400 * ((points - (NbParties - points))/ NbParties)));

    res = RoundSup(res,1);

    return( res );
    }

    /*-----------------------------------------------------------
    Calculer la variation de cote
    -----------------------------------------------------------*/
    function VarCote(p1, p2)
    {
    var Pts, Prev, res;

    Pts = VarCote.arguments[0];
    Prev= VarCote.arguments[1];

    if ((Pts - Prev) < 0)
    res = RoundInf(32*(Pts-Prev));
    else
    res = RoundSup(32*(Pts-Prev));

    return res;
    }
    /*-----------------------------------------------------------
    Calculer les points Bonis
    -----------------------------------------------------------*/
    function Bonis(p1)
    {
    var VarC, MinBonis, res;

    VarC= Bonis.arguments[0];

    if (NbParties < 4) MinBonis = 0;
    else if (NbParties == 4) MinBonis = 24;
    else if (NbParties == 5) MinBonis = 26;
    else if (NbParties == 6) MinBonis = 28;
    else if (NbParties == 7) MinBonis = 30;
    else if (NbParties == 8) MinBonis = 32;
    else if (NbParties == 9) MinBonis = 34;
    else if (NbParties == 10) MinBonis = 36;

    if ((VarC > MinBonis) && (NbParties > 3))
    res = RoundSup(VarC - MinBonis);
    else
    res = 0;

    return res;
    }
    /*-----------------------------------------------------------
    Calculer la nouvelle cote
    -----------------------------------------------------------*/
    function NouvC(p1,p2,p3)
    {
    var VarC, Bonis, Orig, res;

    Orig = parseInt( NouvC.arguments[0]);
    VarC = parseInt( NouvC.arguments[1]);
    Bonis = parseInt( NouvC.arguments[2]);

    res = Orig + VarC + Bonis;

    return res;
    }
    /*-----------------------------------------------------------
    Arrondir à n décimales
    -----------------------------------------------------------*/
    function Round (n,p)
    {
    n = Math.round(n * 100) / 100;
    n = (n + 0.001) + '';
    return n.substring(0, n.indexOf('.') + p);
    }

    /*-----------------------------------------------------------
    Arrondir à l'entier supérieur
    -----------------------------------------------------------*/
    function RoundSup (n)
    {
    var t, res;

    t = Math.round(n);
    if (t < n)
    res = t + 0;
    else
    if (t > n)
    res = t;
    else
    res = t;

    return res;
    }
    /*-----------------------------------------------------------
    Arrondir à l'entier inférieur
    -----------------------------------------------------------*/
    function RoundInf (n)
    {
    var t, res;

    t = Math.round(n);
    if (t < n)
    res = t + 0;
    else
    if (t > n)
    res = t;
    else
    res = t;

    return res;
    }

    j'espère avoir été plus clair

    n'hésite pas a m'écrire si besoin est !!!

    merci bien gros a l'avance !!!

    a+
    0
  3. miramaze Messages postés 1429 Date d'inscription   Statut Contributeur Dernière intervention   92
     
    Je vais regarder ça quand j'aurais 5 mn.
    0
  4. miramaze Messages postés 1429 Date d'inscription   Statut Contributeur Dernière intervention   92
     
    Explique moi exactement les étapes. Qu'est ce qui doit se passer quand on choisit un élement dans le menu déroulant ? Quand on appuie sur "Calculer la cote" ?
    0