Entao pessoal eh o seguinte eu estou fazendo um projeto e nao estou conseguindo fazer ele filtrar enquando eu vou digitando, alguem poderia me ajudar? pois ele so busca se eu preencher o campo e clicar em consultar, eu gostaria de apenas digitar e ele filtrar sozinho sem que precise clicar em consultar....
obrigado por enquanto.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@page import="br.edu.udc.ap6.session.SessionMarca, br.edu.udc.ap6.entity.Marca, br.edu.udc.ap6.entity.EntityObject"%>
<!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>Consultar Marca</title>
<script type="text/javascript">
function limpar() {
window.location.href = "./consultarCliente.jsp";
}
function find() {
document.getElementById("acao").value = "find";
document.getElementById("form").submit();
}
function detail(id) {
document.getElementById("acao").value = "detail";
document.getElementById("id").value = id;
document.getElementById("form").action = "manterMarca.jsp";
document.getElementById("form").submit();
}
function excluir(id) {
document.getElementById("acao").value = "delete";
document.getElementById("id").value = id;
document.getElementById("form").submit();
}
function novo() {
window.location.href = "./manterMarca.jsp";
}
</script>
</head>
<%
String acao = request.getParameter("acao");
Marca marca = new Marca();
try {
marca.setIdMarca(Integer.parseInt(request.getParameter("idMarca")));
} catch (NumberFormatException e) {
marca.setIdMarca(null);
}
marca.setDescricao(request.getParameter("descricao"));
EntityObject listaMarca[] = new Marca[0];
if (acao != null) {
SessionMarca sessionMarca = new SessionMarca();
if (acao.equals("find")) {
listaMarca = sessionMarca.find(marca);
} else if (acao.equals("delete")) {
try {
Marca marcaAux = new Marca();
marcaAux.setIdMarca(Integer.parseInt(request.getParameter("id")));
sessionMarca.delete(marcaAux);
listaMarca = sessionMarca.find(marca);
} catch (NumberFormatException e) {}
}
}
%>
<body>
<table border="0" width="100%" height="305">
<tr>
<td valign="top" height="50">
<form name="form" id="form" method="post" action="./consultarMarca.jsp">
<input type="hidden" name="acao" id="acao">
<input type="hidden" name="id" id="id">
<table border="0">
<tr>
<td align="right" width="100">Código: </td>
<td align="left" width="100%"><input value="<%=(marca.getIdMarca() == null) ? "" : marca.getIdMarca()%>" type="text" id="idMarca" name="idMarca" maxlength="10" style="width:80px;"></td>
</tr>
<tr>
<td align="right">Descrição: </td>
<td align="left"><input value="<%=(marca.getDescricao() == null) ? "" : marca.getDescricao()%>" type="text" id="descricao" name="descricao" maxlength="100" style="width:400px;"></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td valign="top" align="center" height="25">
<input type="button" value="Consultar" onclick="find();">
<input type="button" value="Limpar" onclick="limpar();">
<input type="button" value="Novo" onclick="novo();">
</td>
</tr>
<tr>
<td valign="top">
<table border="1" width="100%">
<tr>
<td width="80" height="25">Código</td>
<td>Descrição</td>
<td width="50"> </td>
</tr>
<%
for (int i=0; i<listaMarca.length; i++) {
Marca marcaAux = (Marca) listaMarca[i];
%>
<tr>
<td width="80" height="25"><%=marcaAux.getIdMarca() %></td>
<td><%=marcaAux.getDescricao() %></td>
<td width="50">
<a href="javascript:detail(<%=marcaAux.getIdMarca() %>);" style="border: 0px;"><img src="../img/lapis.png" style="border: 0px; height: 20px; width: 20px;"/></a>
<a href="javascript:excluir(<%=marcaAux.getIdMarca() %>);" style="border: 0px;"><img src="../img/x.png" style="border: 0px; height: 20px; width: 20px;"/></a>
</td>
</tr>
<%
}
%>
</table>
</td>
</tr>
</table>
</body>
</html>