Sobre busca no banco de dados com input select

0 respostas
J

Companheiros estou com o seguinte problema:
Tenho 2 input select
O primeiro carrega os dados do setor nome e id isso é tranquilo ja esta funcionado
mas o segundo é que é o problema, quando seleciono um determinado registro na tabela de setor, ele deveria fazer buscar os funcinários desse setor, mas não estou conseguindo fazer isso dinâmicamente.
Se alguém tem uma idéia de como fazer isso?
Vou postar aqui o código.

<%-- 
    Document   : formsolicitante
    Created on : 25/03/2009, 11:28:16
    Author     : Jader
--%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ include file="/WEB-INF/jspf/acesso.jspf" %>


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="CSS/corpo.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <%
        String ipAddress = request.getRemoteAddr();
        pageContext.setAttribute("ipAddress", new String(ipAddress));
        %>

        <c:if test="${param.idsetor != null}">
            <c:set var="idsetor" value="${param.idsetor}"/>
        </c:if>

        <sql:query var="listafuncionario" dataSource="${con}">
            SELECT * FROM funcionario WHERE usuario='<%=session.getAttribute("USER")%>'
        </sql:query>

        <sql:query var="listasetor" dataSource="${con}">
            SELECT * FROM setorslave WHERE idsetor='<c:out value="${listafuncionario.rowsByIndex[0][1]}"/>'
        </sql:query>
        
        
        <sql:query var="solicitafuncionario" dataSource="${con}">
            SELECT * FROM funcionario WHERE idsetor='<c:out value="${listafuncionario.rowsByIndex[0][1]}"/>'
        </sql:query>
        <div align="center" class="bbox">Olá <%=session.getAttribute("USER")%>.Essa é sua área restrita. - <c:out value="${maquina}"/></div>
        <html:form  acceptCharset="iso-8859-1" method="post"  action="/solicitante">
            <table align="center" class="content" width="75%" height="1%" border="0" cellpadding="2" cellspacing="2">
                <tr bgcolor="#000066">
                    <td height="19" colspan="2"><strong><font color="#FFFFFF">SOLICITANTE</font></strong></td>
                </tr>
                <tr>
                    <td width="18%" height="22">ID.Setor:</td>
                    <td width="82%"><html:text property="setorM" value="${listasetor.rowsByIndex[0][0]}" readonly="true" size="80"/></td>
                </tr>
                <tr>
                    <td width="18%" height="22">Nome do Setor:</td>
                    <td width="82%"><html:text property="setorsolicitante" value="${listasetor.rowsByIndex[0][1]}" readonly="true" size="80"/></td>
                </tr>
                <tr>
                    <td height="22">Funcionário:</td>
                    <td><html:text property="nomesolicitante" value="${listafuncionario.rowsByIndex[0][2]}" readonly="true" size="50"/></td>
                </tr>
                <tr>
                    <td height="26">Situação:</td>
                    <td><html:text property="situacao" value="${'ABERTO'}" readonly="true" size="50"/></td>
                </tr>
                <tr>
                    <td height="22">Meu IP:</td>
                    <td><html:text property="ipmaquina"  value="${ipAddress}" readonly="true" size="50"/></td>
                </tr>
                <tr>
                    <td height="22">Usuário:</td>
                    <td><html:text property="usuario" value="${listafuncionario.rowsByIndex[0][6]}" size="80"/></td>
                </tr>
                <tr bgcolor="#FF9900">
                    <td height="19" colspan="2"><strong><font color="#000000">SOLICITADO</font></strong></td>
                </tr>

             <tr>
<!--Primeiro input select - seleciona o setor-->
                    <td height="24">Setor:</td>
                    <td><html:select property="setorS">
                        <!--Inserir consulta do setor-->
                            <c:forEach var="setor" items="${listasetor.rowsByIndex}">
                                <html:option  value="${setor[1]}"><c:out value="${setor[2]}"/></html:option>
                            </c:forEach>
                    </html:select></td>
                </tr>

                <tr>
<!--Primeiro input select - seleciona os funcionários do setor-->
                    <td height="24">Funcionário:</td>
                    <td><html:select property="nomesolicitado" >
                            <c:forEach  var="funcionario" items="${solicitafuncionario.rowsByIndex}">
                                <!--Inserir consulta do funcionario-->
                                <html:option  value="${funcionario[2]}"><c:out value="${funcionario[2]}"/></html:option>
                            </c:forEach>
                    </html:select></td>
                </tr>
                <tr>
                    <td height="182">Serviço a Realizar:</td>
                    <td><html:textarea  property="servicorealizar" cols="80" rows="10"></html:textarea></td>
                </tr>
                <tr>
                    <td height="7%" colspan="2"><div align="center">
                            <html:submit value="Enviar"/>
                    </div></td>
                </tr>
            </table>
        </html:form>
        <div class="contentcorpo"><html:errors/></div>
    </body>
</html>
Criado 6 de abril de 2009
Respostas 0
Participantes 1