Foros del Web » Programación para mayores de 30 ;) » Java »

mostrar datos en campos de texto

Estas en el tema de mostrar datos en campos de texto en el foro de Java en Foros del Web. HOLA QUISIERA MOSTRAR LOS DATOS DE MI BD EN CAMPOS DE TEXTO AL MOMENTO DE SELECCIONAR EL CODIGO CON Q EL VALOR ESTA GUARDADO EN ...
  #1 (permalink)  
Antiguo 05/05/2012, 03:18
 
Fecha de Ingreso: abril-2012
Ubicación: surquillo
Mensajes: 44
Antigüedad: 12 años, 1 mes
Puntos: 0
mostrar datos en campos de texto

HOLA QUISIERA MOSTRAR LOS DATOS DE MI BD EN CAMPOS DE TEXTO AL MOMENTO DE SELECCIONAR EL CODIGO CON Q EL VALOR ESTA GUARDADO EN EL CHEKED LE DOY CLICK EN EL BOTON MODIFCAR Y ME MUESTRE LOS DATOS PERO NO ME SALE :( Ayuda xfa
BD SQL
create table producto(
codpro varchar(8) primary key,
descripcion varchar(30),
codma varchar(8),
cod_rubro varchar(8),
cantidad int,
preciou decimal(7,2),
fecomp datetime,
fevenc datetime )

CODIGO
<%@page import="java.text.Normalizer.Form"%>
<%@page import="conec.conexion"%>
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta HTTP-EQUIV="Refresh" CONTENT="15; URL=man_pro.jsp"></meta>
<title>Documento sin título</title>
</head>
<body >

<%
String cod="";
String des="";
String ma="";
String ru="";
int can=0;
Float pre=null;
String fec="";
String fev="";
conexion c = new conexion();
if(request.getParameter("btnmod")!=null){
cod=request.getParameter("checkbox");

ResultSet res=null;
Statement mo=c.getConnection().createStatement();
String sql="Select * from producto where codpro='produ01'";
res=mo.executeQuery(sql);
des=res.getString("descripcion");
ma=res.getString("codma");
ru=res.getString("cod_rubro");
can=res.getInt("cantidad");
pre=res.getFloat("preciou");
fec=res.getString("fecomp");
fev=res.getString("fevenc");
}

%>

<form id="form1" name="form1" method="post" action="">
<table width="100%" height="474" border="1">

<tr>
<td width="32%" height="263"><table width="256" border="1">
<tr>
<td colspan="2">Nuevo Producto</td>
</tr>
<tr>
<td>Codigo </td>
<td><label>
<input type="text" name="txtcod" id="txtcod" value="<% %>" />
</label></td>
</tr>
<tr>
<td width="148">Descripcion</td>
<td width="182"><label for="txtdes2"></label>
<input type="text" name="txtdes" id="txtdes2" value="<% out.print(des); %>"/></td>
</tr>
<tr>
<td>Marca</td>
<td><label for="txtmar"><%

Statement st=c.getConnection().createStatement();
ResultSet rs=st.executeQuery("select * from marca");
out.print("<select name= 'cbo1'>");
while(rs.next()){
out.print("<option value="+rs.getString("codma")+">"+ rs.getString("marca")+"</option>");
}
out.print("</select>");
%></label></td>
</tr>
<tr>
<td>Rubro</td>
<td><label for="txtrub"><%

Statement st1=c.getConnection().createStatement();
ResultSet rs1=st1.executeQuery("select * from rubro");
out.print("<select name= 'cbo2'>");
while(rs1.next()){
out.print("<option value="+rs1.getString("cod_rubro")+">"+ rs1.getString("rubro")+"</option>");
}
out.print("</select>");
%></label></td>
</tr>
<tr>
<td>Cantidad</td>
<td><label for="txtcan"></label>
<input type="text" name="txtcan" id="txtcan" value="<% out.print(can); %>" /></td>
</tr>
<tr>
<td>Precio</td>
<td><label for="txtpre"></label>
<input type="text" name="txtpre" id="txtpre" value="<% out.print(pre); %>" /></td>
</tr>
<tr>
<td>Fecha Compra</td>
<td><label for="txtfec"></label>
<input type="text" name="txtfec" id="txtfec" value="<% out.print(fec); %>" /></td>
</tr>
<tr>
<td>Fecha Venta</td>
<td><label for="txtfev"></label>
<input type="text" name="txtfev" id="txtfev" value="<% out.print(fev); %>" /></td>
</tr>
<tr>
<td colspan="2"><table width="200" border="1">
<tr>
<td><input type="submit" name="btnnue" id="btnnue" value="Nuevo" /></td>
<td><input type="submit" name="btngra" id="btngra" value="Grabar" /></td>
<td><input type="submit" name="btnmod" id="btnmod" value="Modificar" /></td>
<td><input type="submit" name="btneli" id="btneli" value="Eliminar" /></td>
<td><input type="submit" name="btncan" id="btncan" value="Cancelar" /></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="68%">&nbsp;</td>
</tr>
<tr>
<td height="68" colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2"> <CENTER>
<h1>Listado De Productos</h1></CENTER>
<table align="center" border="2" >
<tr>
<td>Codigo</td>
<td>Descripcion</td>
<td>Marca</td>
<td>Rubro</td>
<td>Cantidad</td>
<td>Precio Unitario</td>
<td>Fecha y Hora Compra </td>
<td>Fecha y Hora Vencimiento</td>
</tr>
<%


Statement sen;
ResultSet res=null;
sen=c.getConnection().createStatement();
res=sen.executeQuery("Select * " + "From producto");
while(res.next()){
%>
<td><input type="checkbox" name="checkbox" value="<%=res.getString("codpro") %> "></td>
<td><%=res.getString("descripcion")%></td>
<td><%=res.getString("codma")%></td>
<td><%=res.getString("cod_rubro")%></td>
<td><%=res.getString("cantidad")%></td>
<td><%=res.getString("preciou")%></td>
<td><%=res.getString("fecomp")%></td>
<td><%=res.getString("fevenc")%></td>
</tr>
<%
}
%>
</table>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>
  #2 (permalink)  
Antiguo 06/05/2012, 17:40
Avatar de liloo6retug  
Fecha de Ingreso: junio-2010
Ubicación: Marsella
Mensajes: 109
Antigüedad: 13 años, 10 meses
Puntos: 11
Respuesta: mostrar datos en campos de texto

if(request.getParameter("btnmod")!=null)
{
cod=request.getParameter("checkbox");

//se supone que almacenas el codigo del producto en la variable cod..

y en esta sentencia

String sql="Select * from producto where codpro='produ01'";

//produ01 no es igual a cod... se supone que deberia ir la variable "cod"


hay otras cosas que no entendi... pero revisa esoo

Etiquetas: jsp
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:47.