oui j'utilise le code d'Alicals, mais je comprends pas il me donne rien. j'ai meme copié le code dans un fichier texte entre la balise <html>, et j ai changé l extension en .htm, ca ne donne rien aussi.
Version imprimable
oui j'utilise le code d'Alicals, mais je comprends pas il me donne rien. j'ai meme copié le code dans un fichier texte entre la balise <html>, et j ai changé l extension en .htm, ca ne donne rien aussi.
Je crois que le probleme est posé dans la commande
quand je l'ai enlevé les boutons afficher et cacher marche tres bien, alors y'a t'il une autre methode pour cacher le 2éme formulaire d'une facon que le bouton afficher marche?Code:<div id="form2" style="visibility: hidden;">
Si ca peut t'aider j'ai fait un truc un peu différent....
J'ai deux formulaire. Celui que j'affiche est déterminer par un attribut de session (selon la valeur de l'attibut de session j'affiche le premier ou le 2eme formulaire.
jsp :
J'ai mis un bloc div par formulaire. Et dans le javascript qui est appelé à chaque "load" de la page jsp :Code:
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 <div id = "formuAddGroup"> <h3 class="adminTitle"><bean:message key="administration.adminGroups.title.addGroup"/></h3> <html:errors /> <table class="default"> <html:form action= "/adminGroup" focus="idProfile"> <tr> <td><html:hidden property="whatToDo" value="default"/></td> </tr> <tr> <td><bean:message key="administration.adminGroups.group.text.TitreColGroupId"/></td> <td></td> <td><html:text property="idProfile" value=""/></td> </tr> <tr> <td><bean:message key="administration.adminGroups.group.text.TitreColGroupName" /></td> <td></td> <td><html:text property="nameProfile" value=""/></td> </tr> <tr> <td></td> <td></td> <td><html:submit onclick="return addGroup(this,'addGroup')"><bean:message key='administration.adminGroups.group.button.addGroup'/></html:submit></td> <tr> </html:form> </table> </div> <br> <div id = "formuChangeGroup"> <h3 class="adminTitle"><bean:message key="administration.adminGroups.title.editGroup"/></h3> <html:errors /> <table class="default"> <html:form action= "/adminGroup" focus="idProfile"> <tr> <td><html:hidden property="whatToDo" value="default"/></td> </tr> <tr> <td><bean:message key="administration.adminGroups.group.text.TitreColGroupId"/></td> <td></td> <td><html:text property="idProfile"/></td> </tr> <tr> <td><bean:message key="administration.adminGroups.group.text.TitreColGroupName" /></td> <td></td> <td><html:text property="nameProfile" value=""/></td> </tr> <tr> <td></td> <td></td> <td> <html:submit onclick="changeGroup(this,'changeGroup')"><bean:message key='administration.adminGroups.group.button.changeGroup'/></html:submit> <html:cancel onclick="setWhatToDo(this,'changeGroupCancel')"><bean:message key='administration.adminGroups.group.button.changeGroupCancel'/></html:cancel> </td> <tr> </html:form> </table> </div>
javascript :
Et dans mon action qui correspond : je fais un "setattribute" pour mettre l'attribut "actionAdminGroup" et appeler la fonction show(id), avec id l'id du div (donc du formulaire) qui doit être visible.Code:
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 <SCRIPT language="JavaScript"> window.onload=init; function init(){ alert("init"); var action = "<%=(String)session.getAttribute("actionAdminGroup")%>"; alert(action); show(action); } function show(id) { var d = document.getElementById(id); document.getElementById('formuAddGroup').style.display='none'; document.getElementById('formuChangeGroup').style.display='none'; if (d) {d.style.display='block';} } function setWhatToDo(t, v) { t.form.elements[0].value=v; } function editOrDeleteGroup (t,v){ t.form.elements[0].value=v; var editValue = "deleteGroup"; if (t.form.elements['whatToDo'].value==editValue){ var confirmQuestion = "administration.adminGroups.group.deleteGroup ?" if (!confirm(confirmQuestion)) { return false; } } return true; } function addGroup (t,v) { t.form.elements[0].value=v; var msgalert=""; if (t.form.elements[1].value.length==0){ msgalert += "Le champ group id n'a pas été rempli \n"; } if (t.form.elements[2].value.length==0){ msgalert += "Le champ group n'a pas été rempli \n"; } if (msgalert.length!=0) { alert(msgalert); return false } else { return true; } } function changeGroup (t,v) { t.form.elements[0].value=v; var msgAlert=""; if (t.form.elements[1].value.length==0){ msgalert += "Le champ group id n'a pas été rempli \n"; } if (t.form.elements[2].value.length==0){ msgalert += "Le champ group n'a pas été rempli \n"; } if (msgalert.length!=0) { alert(msgalert); return false } else { return true; } } </SCRIPT>
Sachant que a chaque fois que tu affiche ta page tu passes par ton action, tu peux modifier l'attribut comme tu veux. Mon attribut de type hidden et qui s'appelle 'whatToDo' sert aussi a cela, je le teste dans mon action et en fonction de sa valeur je donne à l'attribut "actionAdminGroup" la valeur désirée pour afficher le bon formulaire.
Voila...si ca peut t'aider.
Anne
c'est tres interessant ce que vous venez de faire, je l'ai essayé et ca marché tres bien.
merci beaucoup pour ton aide.