• 0
Sign in to follow this  
jucacabala

Varios Insert

Question

bom só estou postando porque acho que pode ser util pra muita gente!

meu formulario:

<!-- #include file="../conexao.inc" -->

<%
	DIM conexaodb, str, rs, str1, rs1
	str = "SELECT top 1 * From evento ORDER BY codigo desc "
	call abreconexao
	Set rs = conexaodb.Execute(str)
%>

<html>
<head>
<link href="../estilos.css" rel="stylesheet" type="text/css">

<script language="JavaScript">
<!--
function validaForm(){

  d = document.cadastro;
  if (d.hora1.value == ""){
  	alert("Pelo menos um campo Hora deve ser preenchido!");
  	d.hora1.focus();
  	return false;
  }
  d = document.cadastro;
  if (d.descricao1.value == ""){
  	alert("Pelo menos um campo Descrição deve ser preenchido!");
  	d.descricao1.focus();
  	return false;
  }

  
    return true;
	}

//-->
</script>
<title>::.. J&amp;W Tecnologia de Tr&acirc;nsito ..::</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-top: 0px;
}
-->
</style></head>

<body>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3"><!--#include file="topo2.asp" --></td>
  </tr>
  <tr bgcolor="#0265BD">
    <td colspan="3">&nbsp;</td>
  </tr>
    <%
  if Session("logado")="" then
  Response.Redirect"login.asp"
  End if
  %>
  <tr bgcolor="#0265BD">
    <td width="15" rowspan="3" bgcolor="#0265BD">&nbsp; </td>
    <td width="750" bgcolor="#E5E5E5" class="arial_cinza">&nbsp;&nbsp;Painel de Controle: Eventos </td>
    <td width="15" rowspan="3" bgcolor="#0265BD">&nbsp;</td>
  </tr>
  <tr bgcolor="#0265BD">
    <td><img src="../imagens/spacer.gif" width="10" height="3"></td>
  </tr>
  <tr bgcolor="#0265BD">
    <td bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="10">
      <tr>
        <td>
  <form name="cadastro" method="post" action="evento_programacao2.asp" onSubmit="return validaForm()">
  <input name="codigo" type="hidden" value="<% = rs.Fields("codigo") %>">
  <input name="tipo" type="hidden" value="1">
  <table width="100%"  border="0" cellpadding="1" cellspacing="0" class="arial_azul">
          <tr>
            <td width="100%" colspan="3" bgcolor="#F2FAFD" class="arial_verde"><img src="../imagens/det_noticia.gif" width="11" height="11"> Programa&ccedil;&atilde;o - Municipalizados</td>
            </tr>
          <tr>
            <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="5"></td>
            </tr>
          <tr>
            <td colspan="3" class="arial_textosObs">Obs: o cadastro da programa&ccedil;&atilde;o s&oacute; poder&aacute; ser efetuado com pelo menos um campo hora e descri&ccedil;&atilde;o preenchidos. </td>
          </tr>
          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr valign="top">
            <td width="35%">hora<br>              <input name="hora1" type="text" class="box02" id="hora1"> 
              <span class="arial_textos">(ex.: 00:00)</span> </td>
            <td width="35%">expositor<br>
              <input name="expositor1" type="text" class="box02" id="expositor1"></td>
            <td width="35%">Descri&ccedil;&atilde;o:<br>
                <textarea name="descricao1" cols="40" class="box02" id="descricao1"></textarea></td>
          </tr>
          <tr>
            <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="5"></td>
          </tr>
          <tr valign="top">
            <td>hora<br>
                <input name="hora2" type="text" class="box02" id="hora2">
                <span class="arial_textos">(ex.: 00:00)</span> </td>
            <td>expositor<br>
                <input name="expositor2" type="text" class="box02" id="expositor2"></td>
            <td>Descri&ccedil;&atilde;o:<br>
                <textarea name="descricao2" cols="40" class="box02" id="descricao2"></textarea></td>
          </tr>
          <tr>
            <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="5"></td>
            </tr>
          <tr valign="top">
            <td>hora<br>
                <input name="hora3" type="text" class="box02" id="hora3">
                <span class="arial_textos">(ex.: 00:00)</span> </td>
            <td>expositor<br>
                <input name="expositor3" type="text" class="box02" id="expositor3"></td>
            <td>Descri&ccedil;&atilde;o:<br>
                <textarea name="descricao3" cols="40" class="box02" id="descricao3"></textarea></td>
          </tr>
          <tr>
            <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="5"></td>
          </tr>
          <tr valign="top">
            <td>hora<br>
                <input name="hora4" type="text" class="box02" id="hora4">
                <span class="arial_textos">(ex.: 00:00)</span> </td>
            <td>expositor<br>
                <input name="expositor4" type="text" class="box02" id="expositor4"></td>
            <td>Descri&ccedil;&atilde;o:<br>
                <textarea name="descricao4" cols="40" class="box02" id="descricao4"></textarea></td>
          </tr>
          <tr>
            <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="5"></td>
          </tr>
          <tr valign="top">
            <td>hora<br>
                <input name="hora5" type="text" class="box02" id="hora5">
                <span class="arial_textos">(ex.: 00:00)</span> </td>
            <td>expositor<br>
                <input name="expositor5" type="text" class="box02" id="expositor5"></td>
            <td>Descri&ccedil;&atilde;o:<br>
                <textarea name="descricao5" cols="40" class="box02" id="descricao5"></textarea></td>
          </tr>
          <tr>
            <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="5"></td>
          </tr>
          <tr valign="top">
            <td>hora<br>
                <input name="hora6" type="text" class="box02" id="hora6">
                <span class="arial_textos">(ex.: 00:00)</span> </td>
            <td>expositor<br>
                <input name="expositor6" type="text" class="box02" id="expositor6"></td>
            <td>Descri&ccedil;&atilde;o:<br>
                <textarea name="descricao6" cols="40" class="box02" id="descricao6"></textarea></td>
          </tr>
          <tr>
            <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="5"></td>
          </tr>
          <tr valign="top">
            <td>hora<br>
                <input name="hora7" type="text" class="box02" id="hora7">
                <span class="arial_textos">(ex.: 00:00)</span> </td>
            <td>expositor<br>
                <input name="expositor7" type="text" class="box02" id="expositor7"></td>
            <td>Descri&ccedil;&atilde;o:<br>
                <textarea name="descricao7" cols="40" class="box02" id="descricao7"></textarea></td>
          </tr>
          <tr>
            <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="5"></td>
          </tr>
          <tr valign="top">
            <td>hora<br>
                <input name="hora8" type="text" class="box02" id="hora8">
                <span class="arial_textos">(ex.: 00:00)</span> </td>
            <td>expositor<br>
                <input name="expositor8" type="text" class="box02" id="expositor8"></td>
            <td>Descri&ccedil;&atilde;o:<br>
                <textarea name="descricao8" cols="40" class="box02" id="descricao8"></textarea></td>
          </tr>
          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="3"><input name="imageField" type="image" src="../imagens/bt_cadastrar.gif" width="130" height="25" border="0"></td>
            </tr>
        </table>
  </form>
  </td>
      </tr>
    </table></td>
  </tr>
  <tr bgcolor="#0265BD">
    <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="15"></td>
  </tr>
  <tr bgcolor="#1B3855">
    <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="8"></td>
  </tr>
</table>
</body>
</html>
minha pagina insert "evento_programacao2.asp":
<!-- #include file="../conexao.inc" -->

<%
	DIM conexaodb, str, rs
	Dim codigo, tipo, hora, expositor, descricao

	call abreconexao

	codigo = Request.form("codigo")
	tipo = Request.form("tipo")


	for i=1 to 8
  hora = Trim(request.form("hora" & (i)))
  expositor = Trim(request.form("expositor" & (i)))
  descricao = replace(request.form("descricao" & (i)),chr(13),"<br>")
  
  str = "INSERT INTO programacao (codigo, tipo, hora, expositor, descricao) "
  str = str & "VALUES (" & codigo & "," & tipo & ",#" & hora & "#,'" & expositor & "','" & descricao & "')" 
  
  If Len(hora) > 0 Then
  	Set rs = conexaodb.Execute(str)
  End If
	next

	call fechaconexao

	Response.Redirect "evento_programacao3.asp"

%>

<html>
<head>
<link href="../estilos.css" rel="stylesheet" type="text/css">
<title>::.. J&amp;W Tecnologia de Tr&acirc;nsito ..::</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-top: 0px;
}
-->
</style></head>

<body>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3"><!--#include file="topo2.asp" --></td>
  </tr>
  <tr bgcolor="#0265BD">
    <td colspan="3">&nbsp;</td>
  </tr>
    <%
  if Session("logado")="" then
  Response.Redirect"login.asp"
  End if
  %>
  <tr bgcolor="#0265BD">
    <td width="15" rowspan="3" bgcolor="#0265BD">&nbsp; </td>
    <td width="750" bgcolor="#E5E5E5" class="arial_cinza">&nbsp;&nbsp;Painel de Controle: Eventos </td>
    <td width="15" rowspan="3" bgcolor="#0265BD">&nbsp;</td>
  </tr>
  <tr bgcolor="#0265BD">
    <td><img src="../imagens/spacer.gif" width="10" height="3"></td>
  </tr>
  <tr bgcolor="#0265BD">
    <td height="200" align="center" valign="middle" bgcolor="#FFFFFF" class="arial_textos">Cadastrando Dados... </td>
  </tr>
  <tr bgcolor="#0265BD">
    <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="15"></td>
  </tr>
  <tr bgcolor="#1B3855">
    <td colspan="3"><img src="../imagens/spacer.gif" width="10" height="8"></td>
  </tr>
</table>
</body>
</html>

é isso ai

espero que gostem wink.gif

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

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.

Sign in to follow this