p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: ComboBox, CheckBox, etc ....


Message #1 by "Pedro Henrique" <fariahs@y...> on Tue, 22 Aug 2000 11:59:27
Thank you. I don't speak english very well. But, I can try!
This problem was resolved. I have other questions:
Please, view the code of page 66 of book Professional
Active Server Pages 3.0.
View code in page enprocessor.asp:

<%
...
...
 sb_AbreConexao
 conProcesso.BeginTrans
' Response.Write Request.Form("chkEntrada").Count & "<BR>"
 For Each objItem In Request.Form

  If Request.Form(objItem).Count >= 1 Then

   For I = 1 To Request.Form(objItem).Count

       strEntrada = Request.Form(objItem)(I)

    If UCase(strEntrada) <> "ENTRADA" Then

     pos1 = instr(1, strEntrada, ":")
     pos2 = instr(pos1 + 1, strEntrada, ":")
     Response.Write pos1
     Response.Write pos2

     strCodOEProcesso = mid(strEntrada, 1, pos1 - 1)
     strAnoProcesso = mid(strEntrada, pos1 + 1, 4)
     strNmrProcesso = mid(strEntrada, pos2 + 1, 6)

     'Verifica se o primeiro Check está marcado
    'Check the first checkbox is marked/selected
     Response.Write strEntrada & "<BR>"

     Response.Write strCodOEProcesso & "<BR>"
     Response.Write strAnoProcesso & "<BR>"
     Response.Write strNmrProcesso & "<BR>"

     s_SqlE = "UPDATE TB_TramitacaoProcesso " & _
       "SET dtmDatHoraRcbmto = '" &
DDMMAAAA_MMDDAAAA(formatdatetime(NOW(),vbShortDate)) & " " &
formatdatetime(NOW(),vbLongTime) & "'," & _
       "lngMtrReceptor = " & 512345 & _
       "WHERE intCodOEProcesso = " & strCodOEProcesso & _
       "AND intAnoProcesso = " & strAnoProcesso & _
       "AND lngNmrProcesso = " & strNmrProcesso

 '    conProcesso.Execute s_SqlE
    End If
   Next
  End If
 Next
 conProcesso.CommitTrans
 sb_FechaConexao
%>

My doubt is : How to determine the controls of  form that be CHECKBOX. Only
Checkbox.
Eu desejo recuperar apenas os valores da Caixa de Verificação (CHECKBOX)
I want recover only the values of CHECKBOX and determines the checkbox
marked.

The page enprocesso.asp calls enprocessor.asp

This code of the enprocesso.asp:

<%
  With rsProcesso
   While Not .EOF
    If I mod 2 = 0 Then
     Response.Write "<tr bgcolor='#BEDDEA'>"
    Else
     Response.Write "<tr>"
    End If

    strECheck = .Fields("intCodOEProcesso") & ":" &
.Fields("intAnoProcesso") & ":" & .Fields("lngNmrProcesso")

    Response.Write "<td width='05%' align='center' valign='top'><input
type=checkbox  name='chkEntrada' value='" & strECheck & "' ></td>" & VbCrLf
    'Órgão Emissor do Processo
    Response.Write "<td width='08%' valign='top'><font face=Verdana
size='2'>" & " " & "00" & .Fields("intCodOEProcesso") & "</font></td>"
& VbCrLf
    'Ano do Processo
    Response.Write "<td width='08%' valign='top'><font face=Verdana
size='2'>" & " " & .Fields("intAnoProcesso") & "</font></td>" & VbCrLf
    'Número do Processo
    Response.Write "<td width='12%' valign='top'><font face=Verdana
size='2'>" & " " & .Fields("lngNmrProcesso") & "</font></td>" & VbCrLf
    'Lotação de Origem
    Response.Write "<td width='15%' valign='top'><font face=Verdana
size='2'>" & " " & .Fields("SiglaLotacao") & "</font></td>" & VbCrLf
    'Data de Envio
    Response.Write "<td width='17%' valign='top'><font face=Verdana
size='2'>" & " " & formatdatetime(.Fields("dtmDatHoraCarga"),
vbShortDate) & "</font></td>" & VbCrLf
    'Hora de Envio
    Response.Write "<td width='17%' valign='top'><font face=Verdana
size='2'>" & " " & formatdatetime(.Fields("dtmDatHoraCarga"),
vbShortTime) & "</font></td>" & VbCrLf
    'Matrícula do Emissor
    Response.Write "<td width='18%' valign='top'><font face=Verdana
size='2'>" & " " & Left(.Fields("lngMtrEmissor"),2) & "." &
Mid(.Fields("lngMtrEmissor"),3,3) & "-" & Mid(.Fields("lngMtrEmissor"),6,1)
& "</font></td>" & VbCrLf
    Response.Write "</TR>"
    .MoveNext
    I = I + 1
   Wend
  End With
  sb_FechaConexao
 End If

%>
  </TABLE>
</DIV>

Thank you.


*********************************************************************


----- Original Message -----
From: Pedro Henrique <fariahs@y...>
To: Code Clinic <proasp_codeclinic@p...>
Sent: Tuesday, August 22, 2000 11:59 AM
Subject: [proasp_codeclinic] ComboBox, CheckBox, etc ....


> ****THIS MESSAGE HAS BEEN ALTERED TO INCLUDE A TRANSLATION***
> *****PLEASE, FOLKS SUBMIT MESSAGES IN ENGLISH - I CAN'T******
> ********VOUCH FOR THE ACCURACY OF THESE TRANSLATIONS*********
> *AND I DON'T LIKE PRATTING AROUND WITH SUBSCRIBER'S MESSAGES*
>
> PEDRO'S MESSAGE OPENS THUS...
> Tenho uma combobox na qual seleciono uma determinada Área.
> A partir desta escolha é feita uma consulta (através de um botão Submit),
> onde são retornados todos os Processos que deverão entrar nesta Área.
> Supondo que sejam retornados 2 Processos, automaticamente será gerada
> duas linhas com duas checkboxes. De acordo com a consulta poderão
> ser retornados não só duas, mas várias linhas e, conseqüêntemente
> várias checboxes.
>
> Esta é a página que gera o resultado da consulta com suas respectivas
> checboxes: (enprocesso.asp)
>
> MY TRANSLATION (NOT GUARANTEED ACCURATE):
> I have a combobox in which I have a predefined entry (?). To leave this
> choice a consultation is made (through a Submit button), where the Process
> returns all that will be entered in this Area. Assuming that 2 Processes
> are returned, two strings will automatically be generated with two
> checkboxes. In accordance with the consultation could be returned not
alone
> two, but some strings and, consequentially several checboxes (? D.W.).
>
> This is the page that generates the result of the consultation with its
> respective checboxes: (enprocesso.asp).
>
> ...
> ...
> <SCRIPT language="VBScript">
> Sub chkEntrada_OnClick()
>
> If strECheck = "OFF" Then
> strECheck = "ON"
> Else
> strECheck = "OFF"
> End If
>
> End Sub
> </SCRIPT>
> ...
> ...
> <FORM method="post" action="enprocessor.asp" name="frmEntrada">
> <DIV align="center">
>   <TABLE border="0" width="100%">
>     <TR BGCOLOR="#7BBBD5">
>       <TD width="05%"></TD>
>       <TD width="08%" align="left"><FONT face="Arial"
> size="2">Emissor</FONT></TD>
>       <TD width="08%" align="left"><FONT face="Arial"
> size="2">Ano</FONT></TD>
>       <TD width="12%" align="left"><FONT face="Arial"
> size="2">Número</FONT></TD>
>       <TD width="15%" align="left"><FONT face="Arial"
> size="2">Lotação</FONT></TD>
>       <TD width="17%" align="left"><FONT face="Arial" size="2">Data de
> Envio</FONT></TD>
>       <TD width="17%" align="left"><FONT face="Arial" size="2">Hora de
> Envio</FONT></TD>
>       <TD width="18%" align="left"><FONT face="Arial" size="2">Matrícula
> Emissor</FONT></TD>
>     </TR>
>   </TABLE>
> </DIV>
>
> <DIV align="center">
>   <TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
> <%
> With rsProcesso
> While Not .EOF
> If I mod 2 = 0 Then
> Response.Write "<tr bgcolor='#BEDDEA'>"
> Else
> Response.Write "<tr>"
> End If
>
> Response.Write "<td width='05%' align='center' valign='top'><input
> type=checkbox id='chkEntrada(" & I & ")' name='chkEntrada(" & I & ")'
> value='" & strECheck & "' onclick='chkEntrada_OnClick()'></td>"
> 'Órgão Emissor do Processo
> Response.Write "<td width='08%' valign='top'><font face=Verdana
> size='2'>" & " " & "00" & .Fields("intCodOEProcesso") &
> "</font></td>"
> 'Ano do Processo
> Response.Write "<td width='08%' valign='top'><font face=Verdana
> size='2'>" & " " & .Fields("intAnoProcesso") & "</font></td>"
> 'Número do Processo
> Response.Write "<td width='12%' valign='top'><font face=Verdana
> size='2'>" & " " & .Fields("lngNmrProcesso") & "</font></td>"
> 'Lotação de Origem
> Response.Write "<td width='15%' valign='top'><font face=Verdana
> size='2'>" & " " & .Fields("SiglaLotacao") & "</font></td>"
> 'Data de Envio
> Response.Write "<td width='17%' valign='top'><font face=Verdana
> size='2'>" & " " & formatdatetime(.Fields("dtmDatHoraCarga"),
> vbShortDate) & "</font></td>"
> 'Hora de Envio
> Response.Write "<td width='17%' valign='top'><font face=Verdana
> size='2'>" & " " & formatdatetime(.Fields("dtmDatHoraCarga"),
> vbShortTime) & "</font></td>"
> 'Matrícula do Emissor
> Response.Write "<td width='18%' valign='top'><font face=Verdana
> size='2'>" & " " & Left(.Fields("lngMtrEmissor"),2) & "." &
> Mid(.Fields("lngMtrEmissor"),3,3) & "-" &
> Mid(.Fields("lngMtrEmissor"),6,1)
> & "</font></td>"
> Response.Write "</TR>"
> .MoveNext
> I = I + 1
> Wend
> End With
> sb_FechaConexao
> End If
> NCheck = I - 1
> %>
>   </TABLE>
> </DIV>
> <% Response.Write "<P>"  %>
>
> <INPUT TYPE="Hidden" NAME="txtNCheck" VALUE="<%= NCheck %>">
> <INPUT type="submit" value="Entrada" name="cmdEntrada">
> </FORM>
> </BODY>
> </HTML>
>
> Se usuário marcar apenas a primeira ou a segunda checbox ou ambas,
> deverá ser feito um update em uma tabela. Este update é feito na
> página enprocessor.asp
>
> Como terei de dar request.form em todas as checkboxes, tentei usar
> matriz. O número de checkbox está guardado na variável txtNCheck.
> Veja o código abaixo (enprocessor.asp)
>
> TRANSLATION:
> If only the first or second checbox or both are marked, update in a table
> will have to be made. This update is made in the page enprocessor.asp
>
> As I will have to use request.form for all the checkboxes, I tried to use
> an array (not sure about this bit, D.W.). The number of checkbox is kept
in
> the 0 variable txtNCheck. This is the code (enprocessor.asp):
>
> ...
> ...
> Function DDMMAAAA_MMDDAAAA(data)
> Dim barra_1, barra_2
> Dim dia, mes, ano, datacerta
>
> barra_1 = instr(1,data,"/") 'Retorna a posição da 1ª Barra
> barra_2 = instr(barra_1 + 1,data,"/") 'Retorna a posição da 2ª Barra
>
> dia = Mid(data,1,barra_1 - 1)
> mes = Mid(data,barra_1 + 1,barra_2 - barra_1 -1)
> ano = mid(data,barra_2 + 1)
> datacerta = mes + "/" + dia + "/" + ano
> DDMMAAAA_MMDDAAAA = datacerta
> End Function
>
> ...
> ...
> ...
> NCheck = Request.Form("txtNCheck")
> Response.Write ncheck
>
> sb_AbreConexao
>
> For I = 1 To NCheck
> strEntrada = Request.Form("chkEntrada")(I)
>
>
> If UCase(strEntrada) = "ON" Then
>
> 'Verifica se o primeiro Check está marcado
> s_SqlE = "UPDATE TB_TramitacaoProcesso " & _
> "SET dtmDatHoraRcbmto = '" &
> DDMMAAAA_MMDDAAAA(formatdatetime(NOW(),2)) & " " & formatdatetime(NOW(),3)
> & "'," & _
> "lngMtrReceptor = " & 512345 & _
> "WHERE intCodOEProcesso = " & 0092 & _
> "AND intAnoProcesso = " & 2000 & _
> "AND lngNmrProcesso = " & 222333
>
> conProcesso.Execute 's_SqlE
> End If
> Next
> ...
>
>
> Como faço para determinar o valor de cada checkbox? (ON/OFF)
> Objetivo: As linhas que contiver o checkbox com o valor "ON"
> deverão ser atualizadas na página enprocessor.asp.
> A sintaxe está correta? O que eu devo fazer?
> Veja o erro que está sendo mostrado:
>
> TRANSLATION:
> How can I determine the value of each checkbox? (On/off)
> Objective: The strings of checkboxes with value " ON " will have to be
> brought up to date in the page enprocessorasp. Is the syntax correct? What
> changes must I make? This is the error that is being shown:
>
> Objeto Request error 'ASP 0105 : 80004005'
>
> Índice fora do intervalo
>
> /SIPRO/enprocessor.asp, line 53
>
> Qualquer índice de matriz está fora do intervalo.
>
> Feito isso, o devo fazer para atualizar a linha certa no
> banco de dados (database).
>
> Caso seja necessário o código todo, por favor solicitem.
> Consta de duas páginas: enprocesso.asp e enprocessor.asp
> Obrigado.
>
> TRANSLATION:
> Any index of array is is of the interval.
>
> With this, I must make it bring up to date the relevant string in the
> database.
>
> In case that it is necessary the code all, please they request.
> It consists of two pages: enprocesso.asp and enprocessor.asp
> Obliged.
>
> ***I HAVEN'T TRIED READING THE CODE, BECAUSE THE TRANSLATION***
> ****TOOK LONG ENOUGH... HOPEFULLY SOMEONE ELSE WILL BE ABLE****
> *******TO HELP. ONCE AGAIN, IN ENGLISH IN FUTURE, PLEASE*******
>
> ---
> You are currently subscribed to proasp_codeclinic.
$subst('Email.Unsub')
>
>


  Return to Index