Hi to all,

I want to create a jsp page where user will insert in second combo box his choice and then based on his selection, in the third combo box there will be only choices that are connected with choice from second combo-box.

here is the code:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>   

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Unos kandidata</title>
</head>
<jsp:useBean id="autoskole" class="autoskola.managers.SveAutoSkole" scope="page"/>
<jsp:useBean id="kategorije" class="autoskola.managers.SveKategorije" scope="page"/>
<jsp:useBean id="instruktori" class="autoskola.managers.SviInstruktori" scope="page"/>


<body>
<form action="/AutoSkola/KandidatServlet" method="post">
Unesite podatke za novog kandidata:
<br>
<br>
<table>

 <tr><td>Ime</td><td><input type="text" name="ime"></td></tr>
 <tr><td>Prezime</td><td><input type="text" name="prezime"></td></tr>
 <tr><td>Adresa</td><td><input type="text" name="adresa"></td></tr>
 <tr><td>Telefon</td><td><input type="text" name="telefon"></td></tr>
 <tr><td>Jmbg</td><td><input type="text" name="jmbg"></td></tr>
 <tr><td>Email</td><td><input type="text" name="email"></td></tr>
  <tr><td>Izaberi autoskolu:</td>
<tr><td>
<select name="bpautoskola">
<c:forEach var="bpautoskola" items="${autoskole.sveAutoskole}">
<option value="${bpautoskola.idSkole}" >${bpautoskola.naziv}</option>
</c:forEach>
</select>
</td>

<tr><td>Izaberi kategoriju:</td>
<tr><td>
<select name="bpkategorija">
<c:forEach var="bpk" items="${kategorije.sveKategorije}">
<option value="${bpk.idKategorije}" >${bpk.oznakaKategorije}</option>
</c:forEach>
</select>
</td>
</tr>

<tr><td>Izaberi instruktora:</td>
<tr><td>
<select name="bpinstruktor">
<c:forEach var="bpi" items="${instruktori.sviInstruktori}">
<option value="${bpi.idInstruktora}" >${bpi.ime} ${bpi.prezime}</option>
</c:forEach>
</select>
</td>
</tr>

</table>
<br>
<br>
<input type="submit" value="Sacuvaj">

 </form>

${poruka} 


</body>
</html>

He reads all from local database, and I'm trying to find a solution for my problem... Language is Serbian, I have a Driving school where user will select category that he wants, then he will select driving school from combo box, and then he will have choice to select driver instructor who works at that school...

Recommended Answers

All 4 Replies

Member Avatar for LastMitch

I want to create a jsp page where user will insert in second combo box his choice and then based on his selection, in the third combo box there will be only choices that are connected with choice from second combo-box.

I'm not very familiar with JSP codes. Are you having issue fetchin the data from the database or displaying it?

I think you need to do something like this:

http://www.skywayperspectives.org/documentation/6.3/chunk/recipes/ch02s20.html

I can display all of them. (3 combo boxes). But I need to disable one of them, until some choices from other combo box are configured. (First, I need to choose Driving school that I want, and later depending of which school did I choose, I need to get instructors who worked there- I already make instructors and tell in which school they work)

At the moment, I see all instructors from all schools, and I can insert it in that way in my database, but it doesn't have any logic, e.g. my instructor Kevin works for school DRIVING, and my candidate selected another school, and chose Kevin for his instructor

Member Avatar for LastMitch

At the moment, I see all instructors from all schools, and I can insert it in that way in my database, but it doesn't have any logic, e.g. my instructor Kevin works for school DRIVING, and my candidate selected another school, and chose Kevin for his instructor

Include this javascript code to your JSP selection code:

http://www.java2s.com/Code/JavaScript/Form-Control/Disableandenableadropdownlistcombobox.htm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.