Foros del Web » Programando para Internet » ASP Clásico »

problema al cargar pagina con input y boton

Estas en el tema de problema al cargar pagina con input y boton en el foro de ASP Clásico en Foros del Web. tengo este formulario Código: <% Dim id_sistema, nombre, linea, strCondicion id_sistema = cint(request.Form("sistemas")) nombre = request.Form("nombre") linea = request.Form("linea") if id_sistema <> "" then sSQL ...
  #1 (permalink)  
Antiguo 22/10/2007, 16:29
Avatar de Gaby_Corr  
Fecha de Ingreso: junio-2005
Mensajes: 672
Antigüedad: 19 años, 10 meses
Puntos: 0
problema al cargar pagina con input y boton

tengo este formulario

Código:
<%
Dim id_sistema, nombre, linea, strCondicion

id_sistema = cint(request.Form("sistemas"))
nombre = request.Form("nombre")
linea = request.Form("linea")
if id_sistema <> "" then
  sSQL = "Select sistemas_id, sistemas_nombre, sistemas_linea FROM DS_Sistemas where sistemas_id = '"& id_sistema &"'"
	Set rs = cnn.execute(sSQL) 
	
	if not rs.eof then
		Sistema = rs("sistemas_id")
		Nombre = rs("sistemas_nombre")
		Linea = rs("sistemas_linea")
		strCondicion = 0		
	else
		strCondicion = 1
		Sistema = id_sistema
		Nombre = ""
		Linea = ""	
		
	end if
	rs.close
end if

%>

<html>.....

<form method="post" action="<%request.ServerVariables("SCRIPT_NAME")%>" id="form1" name="form1">

<table width="100%" cellpadding="0" cellspacing="0">		    
<tr><td>Número de Sistema: <br /><span class="dtobligatorio"> * </span><
	<input name="sistemas" type="text" id="sistemas" value="<%=Sistema%>" size="20" maxlength="20" />
	<input name="ver" type="image" id="ver" value="ver" src="Images/20_VER1.jpg" />	
	 </td></tr>
	
<tr><td>Nombre del sistema: <br /><span class="dtobligatorio"> * </span>
   <input name="nombre" type="text" id="nombre" value="<%=Nombre%>" size="95" maxlength="30" />
</td>
</tr>
<tr><td>Línea de sistemas:<br /><span class="dtobligatorio"> * </span>
<input name="linea" type="text" id="linea" value="<%=Linea%>" size="95" maxlength="30"/>

<input type="hidden" name="sistemas" value="<%=idSistema%>">



<% if strCondicion = 1 then %>
<input name="Guardar" type="image" id="Guardar" src="http://www.forosdelweb.com/images/GUARDAR1.gif"  style=" visibility: visible;"  onclick="Mtdos(this)" />
<% end if%>

...
</html>

Al iniciar estan los 3 botones y al darle valor al primero quiero que vaya y verifique en una tabla, sino existe pues que me despliegue el boton de guardar, lo he logrado solo quiero que inicialmente cuando cargo la pagina el input id=sistema este en blanco pero ahorita lo que tiene es un cero !! com le puedo hacer para quitarlo??
creo q es cuestion de la variable Sistema pero no hayo como solucionarlo

saludos
__________________
" Recuerda , estas donde debes estar ..."
  #2 (permalink)  
Antiguo 22/10/2007, 23:38
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 18 años, 1 mes
Puntos: 88
Re: problema al cargar pagina con input y boton



algo asi funcionaria....
Cita:
<%if (idSistema=0 or IsNull(idSistema)) then idSistema="" end if%>
<input type="hidden" name="sistemas" value="<%=idSistema%>">
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
  #3 (permalink)  
Antiguo 23/10/2007, 09:24
Avatar de Gaby_Corr  
Fecha de Ingreso: junio-2005
Mensajes: 672
Antigüedad: 19 años, 10 meses
Puntos: 0
Re: problema al cargar pagina con input y boton

bueno ya pude evitar que aparezca el cero en mi primer input, pero persiste el boton de guardar al cargar la pagina ahora le puse esta condicion para ver como funcionaba la variable strcondicion

<table align="left">
<tr>
<% if strCondicion = 1 then %>
<td width="167" height="36">
<input name="Guardar" type="image" value="submit" id="Guardar" src="http://www.forosdelweb.com/images/GUARDAR1.gif" style=" visibility: visible;" onclick="Metodos(this.id)" />

</td>
<% else if strCondicion = 0 then%>
<td width="167" height="36">
<input name="Modificar" type="image" id="Modificar" src="http://www.forosdelweb.com/images/modificar1.gif" style=" visibility:visible;" /></td>
<td width="159">
<input name="Borrar" type="image" id="Borrar" src="Images/ELIMINAR1.gif" style=" visibility: visible;" /></td>
<td width="72">
<input type="image" src="http://www.forosdelweb.com/images/IMPRIMIR1.gif" name="Imprimir" id="Imprimir" style=" visibility: visible;" /></td>
<%end if end if%>
</tr>
<input type="hidden" id="metodo" name="metodo" />

</table>
__________________
" Recuerda , estas donde debes estar ..."

Última edición por Gaby_Corr; 23/10/2007 a las 09:30 Razón: agregué codigo
  #4 (permalink)  
Antiguo 23/10/2007, 10:06
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 18 años, 1 mes
Puntos: 88
Re: problema al cargar pagina con input y boton

gaby, analizemos, tu boton solo aparece si no existe, verdad???

ok... en caso afirmativo, modifiquemos tu Funcion de busqueda un poco.....
Cita:
function buscar(sistema)
call conectarDB
Dim sSQL, rs
sSQL = "Select sistemas_id, sistemas_nombre, sistemas_linea FROM DS_Sistemas where sistemas_id = '"& sistema &"'"
Set rs = cnn.execute(sSQL)

if Err=0 then
%> <table align="left">
<tr>
<%
'si es el final del archivo, NO EXISTE, mandamos el boton GUARDAR

if rs.eof=true then
%>
<td width="167" height="36">
<input name="Guardar" type="image" value="submit" id="Guardar" src="http://www.forosdelweb.com/images/GUARDAR1.gif" style=" visibility: visible;" onclick="Metodos(this.id)" />

</td>
<%
'SI EXISTE, mandamos los botones MODIFICAR, BORRAR, IMPRIMIR
else%>

<td width="167" height="36">
<input name="Modificar" type="image" id="Modificar" src="http://www.forosdelweb.com/images/modificar1.gif" style=" visibility:visible;" /></td>
<td width="159">
<input name="Borrar" type="image" id="Borrar" src="Images/ELIMINAR1.gif" style=" visibility: visible;" /></td>
<td width="72">
<input type="image" src="http://www.forosdelweb.com/images/IMPRIMIR1.gif" name="Imprimir" id="Imprimir" style=" visibility: visible;" /></td>
<%end if%>
</tr>
<input type="hidden" id="metodo" name="metodo" />

</table>
<%end if
call desconectarDB
end function
esto es mas sencillo que traer una variable, lo hacemos directamente desde nuestra busqueda y el resultado es similar....

hay procesos que son mas sencillos, desde el codigo previo, asi no tendras tantos dolores de cabeza

__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
  #5 (permalink)  
Antiguo 23/10/2007, 10:13
Avatar de Gaby_Corr  
Fecha de Ingreso: junio-2005
Mensajes: 672
Antigüedad: 19 años, 10 meses
Puntos: 0
Re: problema al cargar pagina con input y boton

ahora ya me la complique o realmente no se que hacer =S

mi idea es la siguiente tengo estos 3 input los cuales inicialmente no tienen valor
en el input lo que quiero hacer que al darle enter en el input del ID vaya y busque en
una tabla, si existe que me muestre los botones de modificar, eliminar..; sino que me
muestre el boton de guardar.

ahora bien, lo que hice esta mal , porque sino me aparce el boton de guardar,cosa
que tengo ahorita, nunca me haria la busqueda, asi que pensando bien, necesito
que en el input al darle enter o tab, pues vaya y me busque ese dato que acabo de teclear

hace un par de dias me habian stado ayudando pero me confudi con las cosas que tuve que empezarlo
desde cero, asi que necesito que alguien me ayude a resolver mi gran dilema! =(
___________
Id |___________|
___________
Nombre |___________|
___________
Linea |___________|


** inicialmente no deben aparecer ninguno de los botones
| btn_guardar | btn_modificar | btn_eliminar | btn_imprimir |






gracias de antemano!!
__________________
" Recuerda , estas donde debes estar ..."
  #6 (permalink)  
Antiguo 23/10/2007, 11:00
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 18 años, 1 mes
Puntos: 88
Re: problema al cargar pagina con input y boton

bueno.... entonces, hagamos esto.....
pon el codigo que has vuelto a realizar, y partamos desde ahi, ok?
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
  #7 (permalink)  
Antiguo 23/10/2007, 11:15
Avatar de Gaby_Corr  
Fecha de Ingreso: junio-2005
Mensajes: 672
Antigüedad: 19 años, 10 meses
Puntos: 0
Re: problema al cargar pagina con input y boton

ok ok ahi va
sistemas.asp
Código PHP:
<!-- #include file="../conexion.asp"-->

<%
Dim id_sistemanombrelinea

id_sistema 
cint(request.Form("sistemas"))
nombre request.Form("nombre")
linea request.Form("linea")
funcion =request.Form("met")


call conectarDB
if id_sistema <> "" then
  sSQL 
"Select sistemas_id, sistemas_nombre, sistemas_linea FROM DS_Sistemas where sistemas_id = "id_sistema 
    Set rs 
cnn.execute(sSQL
    
    if 
not rs.eof then
        Sistema 
rs("sistemas_id")
        
Nombre rs("sistemas_nombre")
        
Linea rs("sistemas_linea")
        
strCondicion 0        
    
else
        
strCondicion 1
        Sistema 
id_sistema
        Nombre 
""
        
Linea ""    
        
    
end if
    
rs.close

end 
if
%>

<
html>
...
<
body>

<
form method="post" action="<%request.ServerVariables("SCRIPT_NAME")%>"  name="form1" id="form1">

    <
table width="100%" cellpadding="0" cellspacing="0">            
        <
tr><td>Número de Sistema: <br /><span class="dtobligatorio"> * </span><!-- onblur="Busqueda(this.id)" -->
            <%if (
Sistema=or IsNull(Sistema)) then Sistema="" end if%>
            <
input name="sistemas" type="text" id="sistemas" value="<%=Sistema%>" size="20" maxlength="20" onblur="Buscar(this.id)" />
            </
td></tr>
            
        <
tr><td>Nombre del sistema: <br /><span class="dtobligatorio"> * </span>
           <
input name="nombre" type="text" id="nombre" value="<%=Nombre%>" size="95" maxlength="30" />
        </
td>
        </
tr>
        <
tr><td>Línea de sistemas:<br /><span class="dtobligatorio"> * </span>
        <
input name="linea" type="text" id="linea" value="<%=Linea%>" size="95" maxlength="30"/>
    
        <
input type="hidden" name="sistemas" value="<%=idSistema%>">
        </
td></tr>

        <
tr><td><br /><br /></td></tr>                        
        <
tr><td>
            <
table align="left">
            <
tr>
                <% if 
strCondicion 1 then %>
                <
td width="167" height="36">                                    
                    <
input name="Guardar" type="image" value="submit" id="Guardar" src="images/GUARDAR1.gif"  style=" visibility: visible;"  onclick="Metodos(this.id)" />
                
                    </
td>
                <% else if 
strCondicion 0 then%>
                <
td width="167" height="36">
                   <
input name="Modificar" type="image" id="Modificar" src="images/modificar1.gif" style=" visibility:visible;" /></td>
                <
td width="159">
                   <
input name="Borrar" type="image"  id="Borrar" src="Images/ELIMINAR1.gif" style=" visibility: visible;" /></td>
                <
td width="72"
                   <
input  type="image" src="images/IMPRIMIR1.gif" name="Imprimir" id="Imprimir" style=" visibility: visible;" /></td>
                <%
end if  end if%>
            </
tr>
            <
input type="hidden" id="metodo" name="metodo" />
            
            </
table>
        </
td></tr>
        <
tr><td class="dtobligatorio"><br /><br />(*) Datos obligatorios </td></tr>
                
    </
table>
</
form>



</
body>
</
html

asi es como lo tengo ahorita
__________________
" Recuerda , estas donde debes estar ..."
  #8 (permalink)  
Antiguo 23/10/2007, 12:51
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 18 años, 1 mes
Puntos: 88
Re: problema al cargar pagina con input y boton

gaby, los tres inputs, lo llena el usuario y despues verificas???
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
  #9 (permalink)  
Antiguo 23/10/2007, 12:56
Avatar de Gaby_Corr  
Fecha de Ingreso: junio-2005
Mensajes: 672
Antigüedad: 19 años, 10 meses
Puntos: 0
Re: problema al cargar pagina con input y boton

no, el usuario debe llenar el primero y ahi mismo quiero que con el onblur() validar si existe en mi tabla o no, si existe ese valor pues aparecer e boton modificar..., sino existe pues que aparezca el boton grabar.

ahh pero si deben aparecer los 3 inputs inicialmente
__________________
" Recuerda , estas donde debes estar ..."
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 01:54.