Jump to content
Fórum Script Brasil
  • 0

Ajuda Com Select.


nadia_xidea
 Share

Question

Oi gente, tudo bem.

Preciso da ajuda de vocês nesse select, é o seguinte, quando carregar a página do meu site, vai ter um campo de formulário que vai fazer a busca e o outro, aonde abre um menu de lista com todas as categorias que eu quero selecionar pra fazer a busca.

Não sei o que acontece que não está pegando as categorias do banco de dados, aparece a lista em branco, apenas escrito todas as categorias.

também não dá erro...

veja como está a minha conexão com o DB:

Set objCategorias = Server.CreateObject("ADODB.Connection")

objCategorias.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\web\localuser\informenet\banco\noticias.mdb"

objCategorias = "SELECT ID, categorias FROM categorias ORDER BY categorias ASC"

Aqui embaixo é aonde é os campos do formu para exibir as categorias...

<form name="form1" method="post" action="Busca.asp">

<table width="242" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="144"><input name="Buscar" type="text" class="Form120x20" id="Buscar"></td>

<td width="5">&nbsp;</td>

<td width="41"><select name="Categoria" size="1" class="Form120x20">

<%

Response.Write "<option selected value='0'>Todas categorias</option>"

While Not objCategorias.EOF

Response.Write "<option value='"& objCategorias("ID") &"'>"& objCategorias("categorias") &"</option>"

objCategorias.MoveNext : Wend

%>

</select></td>

<td width="13">&nbsp;</td>

<td width="39"><input name="imageField" type="image" src="Images/BotBuscar.gif" width="43" height="19" border="0"></td>

</tr>

</table>

</form>

Alguém pode me ajudar.

Obrigada.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Bom pelo que eu pude perceber, o erro estava depois do MoveNext ":"

para ver o erro da pagina

if err <> 0 then
Response.Write "Erro " & err.Description 
end if
Set objCategorias = Server.CreateObject("ADODB.Connection")
objCategorias.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\web\localuser\informenet\banco\noticias.mdb"
objCategorias = "SELECT ID, categorias FROM categorias ORDER BY categorias ASC"

<form name="form1" method="post" action="Busca.asp">
<table width="242" border="0" cellspacing="0" cellpadding="0">
<tr> 
<td width="144"><input name="Buscar" type="text" class="Form120x20" id="Buscar"></td>
<td width="5">&nbsp;</td>
<td width="41"><select name="Categoria" size="1" class="Form120x20">
<%

Response.Write "<option selected value='0'>Todas categorias</option>"

While Not objCategorias.EOF
Response.Write "<option value='"& objCategorias("ID") &"'>"& objCategorias("categorias") &"</option>"
objCategorias.MoveNext  [color=#FF0000]<----------- Erro estava aqui [/color]  
Wend

%> 
</select></td>
<td width="13">&nbsp;</td>
<td width="39"><input name="imageField" type="image" src="Images/BotBuscar.gif" width="43" height="19" border="0"></td>
</tr>
</table>
</form>

Link to comment
Share on other sites

  • 0

Romero muito obrigada, mas não resolveu o problema...

Não carrega nenhum erro e também não exibe as categorias na lista...

estou postando o código completo da página.

Quem puder ajudar fico grata.

<link href="Estilos.css" rel="stylesheet" type="text/css">
<%

Function Horario ( Hoje )
 Dia = Day(date)
 mês = Month(date)
 Ano = Year(date)

 Hoje = Dia & " / " & mês  & " / " & Ano
 Horario = Hoje
End Function

Set objCategorias = Server.CreateObject("ADODB.Connection")
objCategorias.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\web\localuser\infoweb\banco\noticias.mdb"
objCategorias = "SELECT ID, categorias FROM categorias ORDER BY categorias ASC"

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sem t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="778" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="778" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td><table width="777" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="20"><img src="images/img_topo_01.gif" width="20" height="8"></td>
                <td width="756"><img src="images/img_topo_02.gif" width="728" height="8"></td>
                <td width="10"><img src="images/img_topo_03.gif" width="30" height="8"></td>
              </tr>
              <tr> 
                <td><img src="images/img_topo_04.gif" width="20" height="90"></td>
                <td><img src="images/img_topo_05.gif" width="728" height="90"></td>
                <td><img src="images/img_topo_06.gif" width="30" height="90"></td>
              </tr>
              <tr> 
                <td><img src="images/img_topo_07.gif" width="20" height="9"></td>
                <td><img src="images/img_topo_08.gif" width="728" height="9"></td>
                <td><img src="images/img_topo_09.gif" width="30" height="9"></td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td><table width="778" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="389"><img src="images/img_topo_10.gif" width="389" height="49"></td>
                <td width="291"><img src="images/img_topo_11.gif" width="263" height="49"></td>
                <td width="98"><img src="images/img_topo_12.gif" width="126" height="49"></td>
              </tr>
              <tr> 
                <td><img src="images/img_topo_13.gif" width="389" height="25"></td>
                <td background="images/img_topo_14.gif"><font color="#FFFFFF">Hoje 
                  &eacute; dia:</font> 
                  <% = Horario ( Hoje ) %>
                </td>
                <td><img src="images/img_topo_15.gif" width="126" height="25"></td>
              </tr>
              <tr> 
                <td><img src="images/img_topo_16.gif" width="389" height="14"></td>
                <td><img src="images/img_topo_17.gif" width="263" height="14"></td>
                <td><img src="images/img_topo_18.gif" width="126" height="14"></td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td><table width="778" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="300"><img src="images/img_topo_20.gif" width="291" height="29"></td>
                <td width="202"><form name="form1" method="post" action="Busca.asp">
                    <table width="242" border="0" cellspacing="0" cellpadding="0">
                      <tr> 
                        <td width="144"><input name="Buscar" type="text" class="Form120x20" id="Buscar"></td>
                        <td width="5">&nbsp;</td>
                        <td width="41"><select name="Categoria" size="1" class="Form120x20">
                            
                            <%
                                
        Response.Write "<option selected value='0'>Todas categorias</option>"
        
        While Not objCategorias.EOF
            Response.Write "<option value='"& objCategorias("ID") &"'>"& objCategorias("categorias") &"</option>"
        objCategorias.MoveNext
        Wend
        
        %>        
                        </select></td>
                        <td width="13">&nbsp;</td>
                        <td width="39"><input name="imageField" type="image" src="Images/BotBuscar.gif" width="43" height="19" border="0"></td>
                      </tr>
                    </table>
                  </form></td>
                <td width="164">&nbsp;</td>
                <td width="112">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      151k
    • Total Posts
      649.1k
×
×
  • Create New...