bonjour tout le monde,
je travaille actuellement sur une application en jsf, un formulaire contanant plusieurs champs ,je dois avoir en fin de compte la somme de ces champs qui sera affiché dans le output
Le calcul est fait en javascript
Il me semble qu'il n'ya aucune erreur, mais le resultat n'est pas là je suis egaré
voiçi le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<script type="text/JavaScript" language="JavaScript">
 
function checkop(form)
{
	var first = document.getElementById("form:first").value;
	var second document.getElementById("form:second").value;
	var third = document.getElementById("form:third").value;
	var fourth = document.getElementById("form:fourth").value;
	var fiveth = document.getElementById("form:fiveth").value;
	var sixth = document.getElementById("form:sixth").value;
	var operator = "+";
 
	var operand1 = first;
	var operand2 = second;
	var operand3 = third;
	var operand4 = fourth;
	var operand5 = fiveth;
	var operand6 = sixth;
 
	var res = eval(operand1 + operator + operand2 + operator + operand3 + operator + operand4 + operator + operand5 + operator + operand6);
	var opres = document.getElementById("form:opres");
	opres.value = res;
 
}
</script>
Le code jsf :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<h:form  id="op" name="op">
 
                <a4j:outputPanel id="table0">
                 <table border="1" class="dr-table rich-table" style=" width : 840px;">
 
                 <tbody>
                    <tr>
                       <td> <rich:inputNumberSpinner name="first" id="first" value="0" minValue="0" maxValue="2"/></td>
                    </tr>
                    <tr>
                        <td> <rich:inputNumberSpinner value="0" name="second" id="second" minValue="0" maxValue="2"/></td>
                    </tr>
                    <tr>
                         <td> <rich:inputNumberSpinner value="0" name="third" id="third"  minValue="0" maxValue="2"/></td>
                    </tr>
                    <tr>
                       <td> <rich:inputNumberSpinner value="0" name="fourth" id="fourth"  minValue="0" maxValue="2"/></td>
                    </tr>
                    <tr>
                        <td> <rich:inputNumberSpinner value="0" name="fiveth" id="fiveth" minValue="0" maxValue="2"/></td>
                    </tr>
                    <tr>
                      <td> <rich:inputNumberSpinner value="0" name="sixth" id="sixth" minValue="0" maxValue="2"/></td>
                    </tr>
                    <tr>
                        <td colspan="4">  <h:outputText value=" Score "/>
                          </td>
                          <td> <h:outputText id="opres" value="" /> </td>
 
                    </tr>
                     <tr>
 
                          <td> <h:commandButton name="go" value="Calculer" onclick="checkop(op)"/>
                              </td>
                    </tr>
            </tbody>
        </table>
        </a4j:outputPanel>
           </h:form>