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

problemas con selected

Estas en el tema de problemas con selected en el foro de ASP Clásico en Foros del Web. hola tengo el siguiente problema y no entido porque me esta saliendo ya que esto lo he hecho varias veces ok, toy haciendo una pagina ...
  #1 (permalink)  
Antiguo 02/01/2008, 15:21
 
Fecha de Ingreso: enero-2006
Mensajes: 233
Antigüedad: 18 años, 5 meses
Puntos: 2
problemas con selected

hola
tengo el siguiente problema y no entido porque me esta saliendo ya que esto lo he hecho varias veces
ok, toy haciendo una pagina para editar el contenido de una tabla unos de esos campos biene de otra tabla asi q tengo select o una lista para
llamar esa tabla
la idea es que el valor q esta en la tabla que quiero editar quede como selected para q no se cambie el valor en caso de q
voy a editar otro campo y ese lo quierio dejar como esta
buen he intentado de varias formas cuando hago esta comparacion

if rst("IDCLIENTE") = "rstcliente" then response.write "selected"
rstcliente lo pongo entre " no me hace nada
si le quito las comillas me manda este error
microsoft vbscript runtime error '800a000d' type mismatch
y si lo fuerzo
ejemplo
if rst("IDCLIENTE") = "3" then response.write "selected"
entonces si me hace el selected osea esea no se que es lo que estoy haciendo mal les muestro el codigo
gracias
Código:
strsqld = "SELECT * FROM design_base WHERE idcliente = "&idcliente&" and codigo_diseno='"&codigo&"'"
set rstd = conn.execute(strsqld)
if not rstd.eof then
dim rstcliente
	rstcliente = rstd("idcliente")
	end if
		strsql = "SELECT IDCLIENTE, NOMBRE FROM cliente "
	                 set rst = conn.execute(strsql)
                                 %>
          <select size="1" name="cliente">
				    <%	
				  		if not rst.eof then
        				do while not rst.eof
        				
        				%>
                       <option value="<%=rst("IDCLIENTE")%>" <%if rst("IDCLIENTE") = rstcliente then response.write "selected"%> ><%=rst("nombre")%>-<%=rstcliente%></option>

		             <% 
		          
		             rst.movenext
		                loop
		                
	                    end if
	                  rst=close
                      set rst=nothing

					%>

				</select>

Última edición por u_goldman; 02/01/2008 a las 15:34 Razón: Es más legible si se usan las etiquetas de código, los usuarios ten lo agradecerán.
  #2 (permalink)  
Antiguo 02/01/2008, 15:36
Avatar de u_goldman
Moderador
 
Fecha de Ingreso: enero-2002
Mensajes: 8.031
Antigüedad: 22 años, 5 meses
Puntos: 98
Re: problemas con selected

Trata haciendo un cast a entero que creo que es lo que tiene tu ID:

Código:
if rst("IDCLIENTE") = cint(rstcliente) then response.write " selected" end if
Saludos
__________________
"El hombre que ha empezado a vivir seriamente por dentro, empieza a vivir más sencillamente por fuera."
-- Ernest Hemingway
  #3 (permalink)  
Antiguo 02/01/2008, 15:44
 
Fecha de Ingreso: enero-2006
Mensajes: 233
Antigüedad: 18 años, 5 meses
Puntos: 2
Re: problemas con selected

no me manda el mismo error
microsoft vbscript runtime error '800a000d type mismatch'
  #4 (permalink)  
Antiguo 02/01/2008, 15:52
 
Fecha de Ingreso: enero-2006
Mensajes: 233
Antigüedad: 18 años, 5 meses
Puntos: 2
Re: problemas con selected

este campo es de tipo numerico
estoy haciendo el mismo ejercicio
en otra lista lo unico diferente es q el tipo de dato es string y si me funciona este es el codigo
Código:
<select size="1" name="codigo_fill">
				<option value="">Seleccione</option>
				<%
                   strsql5 = "SELECT CODIGO,DESCRIPCION FROM FILLINGSYSTEM"
	              set rst5 = conn.execute(strsql5)
        				if not rst5.eof then
		                do while not rst5.eof %>
	                    <option value="<%=rst5("CODIGO")%>" <% if rst5("CODIGO")=fill  then response.write "selected"%>><%=rst5("CODIGO")%>--<%=rst5("DESCRIPCION")%></option>
		             <% rst5.movenext
		                loop
	                    end if
                      
					%>

              </select>
  #5 (permalink)  
Antiguo 02/01/2008, 15:56
Avatar de u_goldman
Moderador
 
Fecha de Ingreso: enero-2002
Mensajes: 8.031
Antigüedad: 22 años, 5 meses
Puntos: 98
Re: problemas con selected

Tienes que depurar paso a paso, ver que valor es el que esta tirando la excepcion, tendrias que poner todos tus valores para que veamos que esta pasando, hazlo paso a paso y veras el error.
__________________
"El hombre que ha empezado a vivir seriamente por dentro, empieza a vivir más sencillamente por fuera."
-- Ernest Hemingway
  #6 (permalink)  
Antiguo 02/01/2008, 16:03
 
Fecha de Ingreso: enero-2006
Mensajes: 233
Antigüedad: 18 años, 5 meses
Puntos: 2
Re: problemas con selected

Código:
<!-- #include file ="../include/funciones.asp" -->
<%

'Dim fs, a, strRespuesta
Dim strNombreUsuario, strUsuarios
Dim Conn
idcliente = request.querystring("id")
codigo = request.querystring("codigo")


'ABRE CONEXION
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open CONNECTIONSTRING

'VERIFICA EXISTENCIA DE SESION
Call ValidarSesion(TODOS)
strNombreUsuario = Session("NOMBRE")
strsqld = "SELECT * FROM design_base WHERE idcliente = "&idcliente&" and codigo_diseno='"&codigo&"'"
response.write strsqld
set rstd = conn.execute(strsqld)
if not rstd.eof then
	rstcliente = rstd("idcliente")	
	codigod = rstd("codigo_diseno")
	qqq = rstd("codigo_qqq")
    sss = rstd("codigo_sss")
	fill = rstd("codigo_fillingsystem")
	idv = rstd("idvariant")
	ppl = rstd("codigo_ppl")

'set rstd=nothing


%>
<html>
<body>
<div align="center"><img src="../images/cabezote_administrativo.jpg" width="760" height="69"> </div>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  
  <tr valign="top">
    <td> <br>
 <form name="form1" method="post" action="adddesignbase_ok.asp">
   <table width="60%" border="0" cellspacing="0" cellpadding="0" align="center">
     
      <tr bgcolor="#F5F3DD">
        <td height="16" class="text_tetrapakNOALIGNMENT">&nbsp;</td>
        <td height="16" align="center" class="text_tetrapakNOALIGNMENT">
           <table border="0" cellpadding="1" cellspacing="1" class="text_tetrapak">
             <tr><td colspan="2"> <div align="center"><strong><font color="#FF0000" size="1"></font></strong></div></td></tr>
             <tr><td colspan="2"><hr align="center" width="100%" size="1" color="707e67"></td></tr>
             <tr>
              <td width="98" nowrap><strong>Cliente:</strong></td>
              <td width="261"><div align="left">
              
              <% 
                     strsql = "SELECT IDCLIENTE, NOMBRE FROM cliente "
	                 set rst = conn.execute(strsql)
                                 %>
                   <select size="1" name="cliente">
				    <%	
				  		if not rst.eof then
        				do while not rst.eof
        				
        				%>
                       <option value="<%=rst("IDCLIENTE")%>" <%if rst("IDCLIENTE") = "cint(rstcliente)" then response.write "selected"%> ><%=rst("nombre")%>-<%=rstcliente%></option>

		             <% 
		          
		             rst.movenext
		                loop
		                
	                    end if
	                  rst=close
                      set rst=nothing

					%>

				</select></div></td>
             </tr>
             <tr valign="top">
              <td width="98" nowrap><strong>Codigo Diseño:</strong></td>
              <td width="261"><div align="left">
				<select  name="codigo_diseno">
				<option value="" >Seleccione</option>
				<%
                   strsql = "SELECT CODIGO_DISENO, COSTUMER_DESCRIPTION FROM Diseno"
	              set rst = conn.execute(strsql)
        				if not rst.eof then
		                do while not rst.eof %>
	                    <option value="<%=rst("CODIGO_DISENO")%>" <% if rst("CODIGO_DISENO")=codigod  then response.write "selected"%>><%=rst("CODIGO_DISENO")%>--<%=rst("COSTUMER_DESCRIPTION")%></option>
		             <% rst.movenext
		                loop
	                    end if
                       'Conn.Close
                       'Set Conn = nothing
					%>

              </select></div></td>
             </tr>
             <tr valign="top">
              <td width="98" nowrap><strong>Codigo QQQ:</strong></td>
              <td width="261"><div align="left">
				<select  name="codigo_qqq">
				<option value="">Seleccione</option>
						<%
                   strsql = "SELECT CODIGO, DESCRIPCION FROM QQQ"
	              set rst = conn.execute(strsql)
        				if not rst.eof then
		                do while not rst.eof %>
	                    <option value="<%=rst("CODIGO")%>" <% if rst("CODIGO")=qqq  then response.write "selected"%> ><%=rst("CODIGO")%>--<%=rst("DESCRIPCION")%></option>
		             <% rst.movenext
		                loop
	                    end if
                       'Conn.Close
                       'Set Conn = nothing
					%>
              </select></div></td>
             </tr>
             <tr valign="top">
              <td width="98" nowrap><strong>Codigo SSS:</strong></td>
              <td width="261"><div align="left">
				<select size="1" name="codigo_sss">
				<option value="">Seleccione</option>
				<%
                   strsql3 = "SELECT CODIGO, DESCRIPCION FROM SSS"
	              set rst3 = conn.execute(strsql3)
        				if not rst3.eof then
		                do while not rst3.eof %>
	                    <option value="<%=rst3("CODIGO")%>" <% if rst3("CODIGO")=sss  then response.write "selected"%> ><%=rst3("CODIGO")%>--<%=rst3("DESCRIPCION")%></option>
		             <% rst3.movenext
		                loop
	                    end if
                      
					%>

              </select></div></td>
             </tr>
             <tr valign="top">
              <td width="98" nowrap><strong>Codigo PPL:</strong></td>
              <td width="261"><div align="left">
				<select size="1" name="codigo_ppl">
				<option value="">Seleccione</option>
				<%
                   strsql4 = "SELECT CODIGO,Nombre FROM PPL"
	              set rst4 = conn.execute(strsql4)
        				if not rst4.eof then
		                do while not rst4.eof %>
	                    <option value="<%=rst4("CODIGO")%>" <% if rst4("CODIGO")=ppl  then response.write "selected"%> ><%=rst4("CODIGO")%>--<%=rst4("Nombre")%></option>
		             <% rst4.movenext
		                loop
	                    end if
                      
					%>


              </select></div></td>
             </tr>
             <tr valign="top">
              <td width="98" nowrap><strong>Codigo Fillingsysten:</strong></td>
              <td width="261"><div align="left">
				<select size="1" name="codigo_fill">
				<option value="">Seleccione</option>
				<%
                   strsql5 = "SELECT CODIGO,DESCRIPCION FROM FILLINGSYSTEM"
	              set rst5 = conn.execute(strsql5)
        				if not rst5.eof then
		                do while not rst5.eof %>
	                    <option value="<%=rst5("CODIGO")%>" <% if rst5("CODIGO")=fill  then response.write "selected"%>><%=rst5("CODIGO")%>--<%=rst5("DESCRIPCION")%></option>
		             <% rst5.movenext
		                loop
	                    end if
                      
					%>

              </select></div></td>
             </tr>
             <tr valign="top">
              <td width="98" nowrap><strong>ID Variant:</strong></td>
              <td width="261"><div align="left">
				<select size="1" name="idvariant">
				<option value="">Seleccione</option>
				<%
                   strsql6 = "SELECT CODIGO,DESCRIPCION FROM VARIANT"
	              set rst6 = conn.execute(strsql6)
        				if not rst6.eof then
		                do while not rst6.eof %>
	                    <option value="<%=rst6("CODIGO")%>" <% if rst6("CODIGO")= cint(idv)  then response.write "selected"%> ><%=rst6("CODIGO")%>--<%=rst6("DESCRIPCION")%></option>
		             <% rst6.movenext
		                loop
	                    end if
	                    
	                    set rstd=nothing

	                    end if

                       Conn.Close
                       Set Conn = nothing
                       
					%>

              </select></div></td>
             </tr>





                

             <tr><td colspan="2"><hr align="center" width="100%" size="1" color="707e67"></td></tr>
             <tr><td colspan="2"><div align="center">
                 <input name="enviar" type="submit" class="boton_enviar" id="enviar" value="enviar" ></div></td>
             </tr></table>
        </td>
            <td height="16" class="text_tetrapakNOALIGNMENT">&nbsp;</td></tr>
         
        </table>
        </form> 
        </td>
  </tr>
</table>
</body>
</html>
este es todo mi codigo y no funciona en dos listas q son de tipo numerico ya he hecho response.write en los dferentes valores y nada estos son en idcliente y idvariant
aparte de cint hay otra funcion q me permita forsalo a numerico

Última edición por u_goldman; 02/01/2008 a las 16:09
  #7 (permalink)  
Antiguo 02/01/2008, 16:16
 
Fecha de Ingreso: enero-2006
Mensajes: 233
Antigüedad: 18 años, 5 meses
Puntos: 2
Re: problemas con selected

ok
ya me funciona
la solucion poner cint en ambos lados
<%if cint(rst("IDCLIENTE")) =cint(rstcliente) then response.write "selected"%>
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:28.