Bonjour;

Je tourne depuis un bon bout de temps pour fermer une div par défaut à l’ouverture de la jsp, mais sans succès... une idée??? Merci.
J'ai 2 div dans la même jsp et je désir cacher/montrer une div en fonction de la sélection de la liste 'employees'
Voici ma fonction:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
<script>
    window.onload=show('S') ; 
</script>

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script language='javascript'>
    function show(response) {    
        if (response == "N")  {
            optionyes.style.visibility='visible';
            optionyes.style.display='block';
            viewRequestSummary.fileURL.focus();
        } 
        if (response != "N")  {
            optionyes.style.visibility='hidden';
            optionyes.style.display='none';
            diplay:none;
        }
    }
</script>
Quand le choisi une option de la liste déroulante tous fonctionne bien, mais à l’ouverture de la jsp ça ne marche pas!!!
Et voici mon code au complet:
Code java : 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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<%-- Set session-scoped variable to track the view user is coming from.
     This is used by the language mechanism in the Controller so that
     users view the same page when switching between English and Français. --%>
<c:set var='view' value='/employee/manageEmployees' scope='session' />
 
 
 
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
 
 
<style type="text/css">     
    th {  
        padding-left: 5px;
        color:brown;
        background: url(./images/back2.PNG);  
        background-repeat:repeat-x;
    } 
 
 
</style> 
 
<script>
\    window.onload=show('S') ; 
</script>
 
<script language='javascript'>
    function show(response) {    
           if (response == "N")  {
            optionyes.style.visibility='visible';
            optionyes.style.display='block';
            viewRequestSummary.fileURL.focus();
        } 
        if (response != "N")  {
            optionyes.style.visibility='hidden';
            optionyes.style.display='none';
            diplay:none;
        }
    }
</script>
 
 
 
<%-- employee name for list box --%>
<sql:query var="employees" dataSource="jdbc:odbc:LeaveRequest">
    SELECT * FROM Users order by FirstName, LastName
</sql:query>
 
<%-- Group/Team info --%>
<sql:query var="teamLocation" scope="session" dataSource="jdbc:odbc:LeaveRequest">
    SELECT LocationID, DescriptionEn, DescriptionFr FROM TeamLocation 
</sql:query>
 
 
 
<html>
    <head> <div id="title" > Manage Employees </div></head>
<body >
    <form name="manageDataForm" method="get" scope="request" onsubmit="return validateClientData();" >
 
        <div id="optionyes" style="visibility:hidden" >
            <div id="tableCenter">
                <table id ="createTableBorder" width="100%" bordr="1" >
                    <tbody>
                        <tr>    
                            <th colspan="2" align="center" width="100%">Add New Employee</th>
 
                        </tr> 
                        <tr>    
                            <td align="right" >Employee ID </td>
                            <td align="left"> <input type="text" name="employeeID"  /></td>
 
                        </tr>
                        <tr>    
                            <td align="right">User name </td>
                            <td align="left"><input type="text" name="userName"  size="50" /></td>
 
                        </tr>
                        <tr>    
                            <td align="right">Password </td>
                            <td align="left"><input type="text" name="password"  size="50" /></td>
                        </tr>
 
                        <tr>    
                            <td align="right">Team </td>
                            <td align="left"> <select name="team" style="font-weight:bold;" >                 
                                    <c:forEach var="row" items="${teamLocation.rows}">                         
                                        <option value="${row.LocationID}">${row.DescriptionEn}</option>                           
                                    </c:forEach>
                                </select>
                            </td>        
                        </tr> 
                        <tr>    
                            <td align="right">Frist name </td>
                            <td align="left"><input type="text" name="firstname"  size="50"  /></td>
                        </tr>
                        <tr>    
                            <td align="right">Last name </td>
                            <td align="left"><input type="text" name="lastname"  size="50"  /></td>
                        </tr>
                        <tr>    
                            <td align="right">Email </td>
                            <td align="left"><input type="text" name="email"  size="50"  /></td>
                        </tr>
                        <tr>    
                            <td align="right">Telephone </td>
                            <td align="left"><input type="text" name="telephone" value="(613) 111 2222"  size="14"  /></td>
                        </tr>
                        <tr>    
                            <td align="right">Supervisor </td>
                            <td align="left"><input type="checkbox" name="supervisor" value="ON" /></td>
                        </tr>
                        <tr>    
                            <td align="right">Administrator </td>
                            <td align="left"><input type="checkbox" name="admin" value="ON" /></td>
                        </tr>
                        <tr>                           
                            <td colspan="2" align="right"><input type="submit" value="<fmt:message key='c_submit'/>" name="submit" /> </td>                 
                        </tr>         
                        <%--
                    <c:out value="${pageContext.request.method}" />-------------
                    <c:if test="${pageContext.request.method=='POST'}">
 
                        <c:catch var="exception">
                            <sql:update dataSource="jdbc:odbc:LeaveRequest" var="updatedTable">
 
                                INSERT INTO Users (EmployeeID,UserName,Password,Group,FirstName,LastName,Email,Tel,Supervisor,Admin, CreatedBy) VALUES  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
                                <frm:parseNumber value="1234" var="employeeID" />
                                <sql:param value="${username}" />
                                <sql:param value="${password}" />
                                <sql:param value="${firstname}" />
                                <sql:param value="${lastname}" />
                                <sql:param value="${team}" />
                                <sql:param value="${email}" />
                                <sql:param value="${telephone}" />
                                <sql:param value="${upervisor}" />
                                <sql:param value="${admin}" />
                                <sql:param value="${sessionScope.sessionUsername}" />
                            </sql:update>
                            <c:if test="${updatedTable>=1}">
                                <tr>
                                    <td colspan="2">
                                        <font size="3" color='green'> Congratulations ! Employee inserted successfully.</font>
                                    </td>
                                </tr>
                            </c:if>
                        </c:catch>
                        <c:out value="${exception}" />
                        <c:if test="${exception!=null}">
                            <tr>
                                <td colspan="2">
 
                                    <font size="3" color='red'> <c:out value="Warning!!!  Unable to insert data in database.." /></font>
                                </td>
                            </tr>
                        </c:if>
                    </c:if>
--%>
 
                    </tbody>
                </table>
            </div>
        </div>
 
 
 
        <div id="tableView">           
            <table class="space">
                <tbody>
 
                    <%  String personne = request.getParameter("personne");                     
                        pageContext.setAttribute("personne", personne);
                    %>
 
                <c:set var="personnne" value="${personne}"/>
 
                <th id="title" colspan="6" align="left"><%=request.getAttribute("fullName")%> </th>
 
                <th colspan="4" align="right">Select one employee :  
                    <select id="employees"  style="font-weight:bold;" onchange="javascript:show(this.options[this.selectedIndex].value)" >                                                                    
                        <option value="S" ><fmt:message key='v_selectEmployee'/> </option>
                        <option value="N" ><fmt:message key='v_newEmployee'/> </option>
 
                        <c:forEach var="row" items="${employees.rows}">                         
                            <option value="${row.EmployeeID}">${row.FirstName},   ${row.LastName}</option>                           
                        </c:forEach>
                    </select>
                </th>
                <th align="center" ><img src="images/action.gif" width="50" height="23" alt="action"/></th>    
 
                <tr>    
                    <th align="center" width="6%">Emp. Id</th>
                    <th align="center" >Username</th>
                    <th align="center" >Password</th>
                    <th align="center" >First Name</th>
                    <th align="center" >Last Name</th>
                    <th align="center" >Team</th>
                    <th align="center" >Email</th>
                    <th align="center" >Telephone</th>
                    <th align="center" >Sup</th>
                    <th align="center" >Admin</th>  
                    <th align="center" ><a href="javascript:AnyFunction();"> <img src="images/AddEmpl.gif" width="50" height="23" alt="action"/></a></th>    
                </tr> 
 
                <% int ligne = 0;%>
                <c:forEach var="row" items="${employees.rows}">
                    <tr bgcolor="<%= ligne++ % 2 == 0 ? "#ffffff" : "#efffe5" %>" >  
                        <td ><b>${row.EmployeeID}   </b></td>                
                        <td align="left"><b>${row.UserName}     </b></td>
                        <td align="left"><b><c:out value="${row.Password}" /> </b></td>        
                        <td align="left"><b>${row.FirstName}    </b></td>
                        <td align="left"><b>${row.LastName}     </b></td>
                        <td align="left"><b>${row.Group}        </b></td>
                        <td align="left"><b><font size="2" > ${row.Email}   </font> </b></td>
                        <td align="left" style="white-space:nowrap;"><b>${row.Tel}          </b></td>
                    <c:choose>
                        <c:when test="${row.supervisor=='true'}">
                            <td ><b><img src="images/yes.jpg" width="15" height="15" alt="yes"/> </b></td>
                        </c:when>
                        <c:otherwise>
                            <td ><b> &nbsp; </b></td>
                        </c:otherwise>
                    </c:choose>
 
                    <c:choose>
                        <c:when test="${row.admin=='true'}">
                            <td ><b><img src="images/yes.jpg" width="15" height="15" alt="yes"/> </b></td>
                        </c:when>
                        <c:otherwise>
                            <td ><b> &nbsp; </b></td>
                        </c:otherwise>
                    </c:choose>
 
                    <td ><b><a href="mailto:../index.jsp">Edit</a>   </b></td>
                    </tr>                               
                </c:forEach>  
                <tr><td colspan="10" align="right" ><input type="reset" value="Back to Request" onclick="javascript:history.go(-1)" /> </td>                 
                </tr>  
 
                </tbody>
            </table>
        </div> 
    </form>
 
</body>
</html>
 
 
<div id="footer">
 
    <p id="footerText">[ footer text ]</p>
 
</div>