jeudi 14 mai 2015

change option of select based of previous selected item

i really really need your help in my jsp am coding a school app , admin can create levels and also can create groups in each level (java objects). when he wants to register a new student , he needs to specify the level and the group he wants. so i have two selects , the first one has the levels and the second one the groups

<select name="niveau" required="required">
               <% NiveauDaoMysql dao=new NiveauDaoMysql();
             Collection<Niveau> niveaux = new ArrayList<Niveau>();
              niveaux=dao.getListeNiveau();
             Iterator iterator=niveaux.iterator();
                   while ( iterator.hasNext()){
                     Niveau n=(Niveau)iterator.next();
                    %>
    <option value="<%=n.getCodeNiveau()%>"> <%=n.getLibelleNiveau()%> </option>
     <%} %>
    </select>

and i need that once the user selects the level , the second select's options become that level's groups. how can i do that?

Aucun commentaire:

Enregistrer un commentaire