Esqueci de dizer o principal ...só consigo buscar a primeira letra de cada campo, não retorna o campo inteiro. Post novamente abaixo:
Bom dia! Espero contar com a ajuda de vocês. Meu erro deve ser banal mas, como estou apreendendo através de um livro e, ali não encontrei a solução, recorro a alguém mais experiente.
Tento fazer dois scripts em ASP para montar um formulário que servirá para o usuário inserir dados. Alguns dos campos entretanto já estarão pré-preenchidos através de dados resgatados de uma tabela de um Banco de Dados ACCESS. A busca funciona só que, só consigo resgatar a primeira palavra de cada campo e não o campo inteiro. Posto os scripts abaixo, informando que o no SCRIPT 1, "PROCESSO" é um campo alfa-númérico e no SCRIT 2, "Cod1" é um campo numérico. Obrigado!
SCRIPT 1
<%@ CodePage=1252 Language="VBScript"%>
<% Option Explicit %>
<!-- #INCLUDE file="FCKeditor/fckeditor.asp" -->
<!--#Include file="../dbConex.inc"-->
<%
DIM conexaoDataBase, x, cod
cod = request.querystring("cod")
DIM sqlPrinc, rsPrinc, estilo
Call AbreConexao
sqlPrinc = "SELECT * "
SQLPrinc = sqlPrinc + "FROM TabelaPRINCIPAL WHERE PROCESSO = '" +cod+ "' "
Set rsPrinc = conexaoDataBase.Execute(sqlPrinc)
%>
<html>
<head>
<%If not rsPrinc.eof then%>
<title>Processo</title>
<title>DESPACHO</title>
<script LANGUAGE="JAVASCRIPT">
function validaForm()
{
if (document.formdespacho.despacho.value.length <1)
{alert("O campo DESPACHO não pode ficar em branco.");
formdespacho.despacho.focus();
return false;
}
if (document.formdespacho.processo.value.length <1)
{alert("O campo PROCESSO não pode ficar em branco.");
formdespacho.processo.focus();
return false;
}
if (document.formdespacho.fiscal.value.length <1)
{alert("O campo FISCAL não pode ficar em branco.");
formdespacho.fiscal.focus();
return false;
}
return true;
}
</SCRIPT>
</head>
<body>
<p><b><font size="6">PROCESSO <% = rsPrinc("PROCESSO") %></font></b></p>
<form name="formdespacho" method="POST"
ACTION="respnova.asp"onSubmit="return validaForm(this);">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td> PROCESSO: </td>
<td><input type="text" value=<% = rsPrinc("PROCESSO") %> name="processo" size="0">
<td width="20%"> FISCAL: </td>
<td width="80%"><input type="text" value=<% = Session("lgn") %> name="FISCAL" size="10"></tr>
</tr>
<tr>
<td>NOME: </td>
<td><input type="text" value=<% = rsPrinc("DENUNCIADO") %> name="denunciado" size="60"></td>
<tr/>
<td width="20%">ENDEREÇO:
<td width="80%"><input type="text" value=<% = rsPrinc("ENDER") %> name="ender" size="60"></td>
<input type="submit" value="Inserir" name="btInsere">
<input type="reset" value="Limpar campos" name="btLimpa">
<a href="DESPACHAR.asp" class="link"> INICIAL </a>
<a href="Imprimindo1.asp" class="link"> IMPRIMIR OU ALTERAR DESPACHOS</a>
</td>
</tr>
<%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = "/FCKeditor/"
oFCKeditor.Create "FCKeditor1"
%>
</table>
</form>
</body>
</html>
<%end if%>
<%
rsPrinc.Close
Call fechaConexao
Set rsPrinc = Nothing
%>
SCRIPT 2
<%@ CodePage=1252 Language="VBScript"%>
<% Option Explicit %>
<!-- #INCLUDE file="FCKeditor/fckeditor.asp" -->
<!--#Include file="../dbConex.inc"-->
<%
DIM conexaoDataBase, x, cod
cod = request("cod")
DIM sqlPrinc, rsPrinc, estilo
Call AbreConexao
sqlPrinc = "SELECT * FROM DENUNCIA WHERE Cod1 ="+cod
Set rsPrinc = conexaoDataBase.Execute(sqlPrinc)
%>
<html>
<head>
<%If not rsPrinc.eof then%>
<title>Responder Denúncia</title>
<title>DESPACHO</title>
<script LANGUAGE="JAVASCRIPT">
function validaForm() {
if (document.formdespacho.despacho.value.length <1)
{alert("O campo DESPACHO não pode ficar em branco.");
formdespacho.despacho.focus();
return false;
}
if (document.formdespacho.processo.value.length <1)
{alert("O campo PROCESSO não pode ficar em branco.");
formdespacho.processo.focus();
return false;
}
if (document.formdespacho.fiscal.value.length <1)
{alert("O campo FISCAL não pode ficar em branco.");
formdespacho.fiscal.focus();
return false;
}
if (document.formdespacho.denunciado.value.length <1)
{alert("O campo DENUNCIADO não pode ficar em branco.");
formdespacho.fiscal.focus();
return false;
}
if (document.formdespacho.ender.value.length <1)
{alert("O campo ENDEREÇO não pode ficar em branco.");
formdespacho.fiscal.focus();
return false;
}
if (document.formdespacho.num.value.length <1)
{alert("O campo NÚMERO não pode ficar em branco.");
formdespacho.fiscal.focus();
return false;
}
return true;
}
</SCRIPT>
</head>
<body>
<table>
<p><b><font size="6"> DENUNCIA Nº <% = rsPrinc("Cod1") %></font></b></p>
<form name="formdespacho" method="POST"
ACTION="insrespden1.asp" onSubmit="return validaForm(this);">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="20%"> DENUNCIA Nº: </td>
<td width="80%"><input type="text" value=<% = rsPrinc("Cod1") %> name="Cod1" size="0">
<td width="20%"> FISCAL: </td>
<td width="80%"><input type="text" value=<% = Session("lgn") %> name="FISCAL" size="10"></tr>
<tr>
<td width="20%">NOME: </td>
<td width="80%"><input type="text" value=<% = rsPrinc("DENUNCIADO") %> name="denunciado" size="40"></td>
<tr/>
<tr>
<td width="20%">ENDEREÇO:
<td width="80%"><input type="text" value=<% = rsPrinc("ENDER") %> name="ender" size="40"></td>
<td width="20%">NÚMERO:
<td width="80%"><input type="text" value=<% = rsPrinc("NUM") %> name="num" size="10"></td></tr>
<tr>
<td width="20%">COMPLEMENTO:
<td width="80%"><input type="text" value=<% = rsPrinc("comp") %> name="comp" size="30"></td>
<td width="20%">BAIRRO:
<td width="80%"><input type="text" value=<% = rsPrinc("Bairro") %> name="Bairro" size="20"></td> </br>
</tr>
<tr>
<td width="20%">ASSUNTO:
<td width="80%"><input type="text" value=<% = rsPrinc("Assunto") %> name="Assunto" size="30"></td>
<td width="20%">ORIGEM:
<td width="80%"><input type="text" value=<% = rsPrinc("Origem") %> name="Origem" size="20"></td>
<td width="20%">DOC:
<td width="80%"><input type="text" value=<% = rsPrinc("Doc") %> name="Doc" size="10"></td> </br>
</tr>
<tr>
<td width="20%">DENÚNCIA:
<td width="80%"><input type="text" value=<% = rsPrinc("Denuncia") %> name="Denuncia" size="40"></td>
<input type="submit" value="Inserir" name="btInsere">
<input type="reset" value="Limpar campos" name="btLimpa">
<a href="DESPACHAR.asp" class="link"> INICIAL </a>
<a href="Denunciasresp.asp" class="link"> IMPRIMIR OU ALTERAR RESPOSTAS</a>
</tr>
<%
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = "/FCKeditor/"
oFCKeditor.Create "FCKeditor1"
%>
</table>
</form>
</body>
<%end if%>
<%
rsPrinc.Close
Call fechaConexao
Set rsPrinc = Nothing
%>
Pergunta
ramses
Esqueci de dizer o principal ...só consigo buscar a primeira letra de cada campo, não retorna o campo inteiro. Post novamente abaixo:
Bom dia! Espero contar com a ajuda de vocês. Meu erro deve ser banal mas, como estou apreendendo através de um livro e, ali não encontrei a solução, recorro a alguém mais experiente.
Tento fazer dois scripts em ASP para montar um formulário que servirá para o usuário inserir dados. Alguns dos campos entretanto já estarão pré-preenchidos através de dados resgatados de uma tabela de um Banco de Dados ACCESS. A busca funciona só que, só consigo resgatar a primeira palavra de cada campo e não o campo inteiro. Posto os scripts abaixo, informando que o no SCRIPT 1, "PROCESSO" é um campo alfa-númérico e no SCRIT 2, "Cod1" é um campo numérico. Obrigado!
SCRIPT 1 <%@ CodePage=1252 Language="VBScript"%> <% Option Explicit %> <!-- #INCLUDE file="FCKeditor/fckeditor.asp" --> <!--#Include file="../dbConex.inc"--> <% DIM conexaoDataBase, x, cod cod = request.querystring("cod") DIM sqlPrinc, rsPrinc, estilo Call AbreConexao sqlPrinc = "SELECT * " SQLPrinc = sqlPrinc + "FROM TabelaPRINCIPAL WHERE PROCESSO = '" +cod+ "' " Set rsPrinc = conexaoDataBase.Execute(sqlPrinc) %> <html> <head> <%If not rsPrinc.eof then%> <title>Processo</title> <title>DESPACHO</title> <script LANGUAGE="JAVASCRIPT"> function validaForm() { if (document.formdespacho.despacho.value.length <1) {alert("O campo DESPACHO não pode ficar em branco."); formdespacho.despacho.focus(); return false; } if (document.formdespacho.processo.value.length <1) {alert("O campo PROCESSO não pode ficar em branco."); formdespacho.processo.focus(); return false; } if (document.formdespacho.fiscal.value.length <1) {alert("O campo FISCAL não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } return true; } </SCRIPT> </head> <body> <p><b><font size="6">PROCESSO <% = rsPrinc("PROCESSO") %></font></b></p> <form name="formdespacho" method="POST" ACTION="respnova.asp"onSubmit="return validaForm(this);"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td> PROCESSO: </td> <td><input type="text" value=<% = rsPrinc("PROCESSO") %> name="processo" size="0"> <td width="20%"> FISCAL: </td> <td width="80%"><input type="text" value=<% = Session("lgn") %> name="FISCAL" size="10"></tr> </tr> <tr> <td>NOME: </td> <td><input type="text" value=<% = rsPrinc("DENUNCIADO") %> name="denunciado" size="60"></td> <tr/> <td width="20%">ENDEREÇO: <td width="80%"><input type="text" value=<% = rsPrinc("ENDER") %> name="ender" size="60"></td> <input type="submit" value="Inserir" name="btInsere"> <input type="reset" value="Limpar campos" name="btLimpa"> <a href="DESPACHAR.asp" class="link"> INICIAL </a> <a href="Imprimindo1.asp" class="link"> IMPRIMIR OU ALTERAR DESPACHOS</a> </td> </tr> <% Dim oFCKeditor Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = "/FCKeditor/" oFCKeditor.Create "FCKeditor1" %> </table> </form> </body> </html> <%end if%> <% rsPrinc.Close Call fechaConexao Set rsPrinc = Nothing %>SCRIPT 2 <%@ CodePage=1252 Language="VBScript"%> <% Option Explicit %> <!-- #INCLUDE file="FCKeditor/fckeditor.asp" --> <!--#Include file="../dbConex.inc"--> <% DIM conexaoDataBase, x, cod cod = request("cod") DIM sqlPrinc, rsPrinc, estilo Call AbreConexao sqlPrinc = "SELECT * FROM DENUNCIA WHERE Cod1 ="+cod Set rsPrinc = conexaoDataBase.Execute(sqlPrinc) %> <html> <head> <%If not rsPrinc.eof then%> <title>Responder Denúncia</title> <title>DESPACHO</title> <script LANGUAGE="JAVASCRIPT"> function validaForm() { if (document.formdespacho.despacho.value.length <1) {alert("O campo DESPACHO não pode ficar em branco."); formdespacho.despacho.focus(); return false; } if (document.formdespacho.processo.value.length <1) {alert("O campo PROCESSO não pode ficar em branco."); formdespacho.processo.focus(); return false; } if (document.formdespacho.fiscal.value.length <1) {alert("O campo FISCAL não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } if (document.formdespacho.denunciado.value.length <1) {alert("O campo DENUNCIADO não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } if (document.formdespacho.ender.value.length <1) {alert("O campo ENDEREÇO não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } if (document.formdespacho.num.value.length <1) {alert("O campo NÚMERO não pode ficar em branco."); formdespacho.fiscal.focus(); return false; } return true; } </SCRIPT> </head> <body> <table> <p><b><font size="6"> DENUNCIA Nº <% = rsPrinc("Cod1") %></font></b></p> <form name="formdespacho" method="POST" ACTION="insrespden1.asp" onSubmit="return validaForm(this);"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="20%"> DENUNCIA Nº: </td> <td width="80%"><input type="text" value=<% = rsPrinc("Cod1") %> name="Cod1" size="0"> <td width="20%"> FISCAL: </td> <td width="80%"><input type="text" value=<% = Session("lgn") %> name="FISCAL" size="10"></tr> <tr> <td width="20%">NOME: </td> <td width="80%"><input type="text" value=<% = rsPrinc("DENUNCIADO") %> name="denunciado" size="40"></td> <tr/> <tr> <td width="20%">ENDEREÇO: <td width="80%"><input type="text" value=<% = rsPrinc("ENDER") %> name="ender" size="40"></td> <td width="20%">NÚMERO: <td width="80%"><input type="text" value=<% = rsPrinc("NUM") %> name="num" size="10"></td></tr> <tr> <td width="20%">COMPLEMENTO: <td width="80%"><input type="text" value=<% = rsPrinc("comp") %> name="comp" size="30"></td> <td width="20%">BAIRRO: <td width="80%"><input type="text" value=<% = rsPrinc("Bairro") %> name="Bairro" size="20"></td> </br> </tr> <tr> <td width="20%">ASSUNTO: <td width="80%"><input type="text" value=<% = rsPrinc("Assunto") %> name="Assunto" size="30"></td> <td width="20%">ORIGEM: <td width="80%"><input type="text" value=<% = rsPrinc("Origem") %> name="Origem" size="20"></td> <td width="20%">DOC: <td width="80%"><input type="text" value=<% = rsPrinc("Doc") %> name="Doc" size="10"></td> </br> </tr> <tr> <td width="20%">DENÚNCIA: <td width="80%"><input type="text" value=<% = rsPrinc("Denuncia") %> name="Denuncia" size="40"></td> <input type="submit" value="Inserir" name="btInsere"> <input type="reset" value="Limpar campos" name="btLimpa"> <a href="DESPACHAR.asp" class="link"> INICIAL </a> <a href="Denunciasresp.asp" class="link"> IMPRIMIR OU ALTERAR RESPOSTAS</a> </tr> <% Dim oFCKeditor Set oFCKeditor = New FCKeditor oFCKeditor.BasePath = "/FCKeditor/" oFCKeditor.Create "FCKeditor1" %> </table> </form> </body> <%end if%> <% rsPrinc.Close Call fechaConexao Set rsPrinc = Nothing %>Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.