Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

calcio

Selecionar Checkbox de acordo com Condição

Recommended Posts

Galera vejam o código abaixo:

Preciso q ele selecione todas as Checkbox cujo o CDSTATUSPEDIDO seja =9

 

agradeço desde já:

OBS ñ se assutem com o Cod só preciso fazer o JS passar selecionar o status certo. A função q estou usando é SelecionaFinalizados()

 

<!--#include file="inclusoes/connect.asp" --><!--#include file="inclusoes/funcdata.asp" --><%'On Error Resume next Acao            = Request("acao") idpedido        = Request.form("idpedido") dtpedido        = Request.form("dtpedido") dtentrega       = Request.form("dtentrega") idrepresentante = Request.form("idrepresentante") id              = request.form("id") alterar         = request.form("alterar") dtfaturamento   = Request.form("dtfaturamento") VlFrete         = int( Request.form("VlFrete") ) qdproduto       = int( Request.form("qdproduto")) vlproduto       = int( Request.form("vlproduto") ) DtPedidoIni     = Request.form("DtPedidoIni") DtPedidoFim     = Request.form("DtPedidoFim") DtEntregaIni    = Request.form("DtEntregaIni") DtEntregaFim    = Request.form("DtEntregaFim") pagina          = int(request("pagina")) ordenacao       = request("ordem") ordem           = request("ordem") Vpessoal        = request("Vpessoal") tmpessoal       = request("tmpessoal") if verificaacesso(8) then administracao = true titulo          = "Ordem de Faturamento" erro            = 0 'trata data na alteracaoif Len(trim(Vpessoal)) > 0 then  sql = "Select * from pessoal where idtipopessoal<>4 "  sql = sql & " and Cdpessoal=" & trim(Vpessoal)    sql = sql & " order by nmpessoal"  set rstemp = conntemp.execute(sql)  if not rstemp.eof then    idrepresentante = rstemp("idpessoal")  end if   set rstemp = nothingend if  if alterar = "A" then if Len(trim(dtfaturamento)) = 0 then dtfaturamento = dtentregaEnd ifif isnull(ordenacao) or ordenacao = "" Then ordenacao = "idpedido"if Len(Trim(idpedido)) = 0 then idpedido = 0if instr(ordenacao,"DESC") then sentido="" else sentido=" DESC"dtfaturamento = datamdy(dtfaturamento)'alterarif alterar = "A" then'valor total do produto VTP = ( (qdproduto/1000 * vlproduto) + vlfrete ) VTP = formatnumber(VTP) sql = "update pedidos set dtfaturamento=#"& dtfaturamento &"#" sql = sql & ", vltotal="& replace(VTP, ",", "." ) sql = sql & ", vlfrete="& replace(vlfrete, ",", ".") &" Where idpedido="& id set rstemp = conntemp.execute(sql) 'TrataErro set rstemp = nothingEnd if'consulta o representante que estever logado ...if len(Idrepresentante) = 0 then   set rstemp = conntemp.execute("Select * From Pessoal Where CdLogin='" & Session(UID) & "'")  'TrataErro   IdRepresentante = rstemp("IdPessoal")   set rstemp = nothingend if    if Acao = "C" then'Modificado por Marcelo Menezes dia 20/10/2004 às 14:18'Esse Select tinha o TOP 10  sqlCons = "SELECT Pedidos.IdPedido,Pedidos.CdStatusPedido, Pedidos.DtPedido, Pedidos.DtEntrega,Pedidos.DtFinalizacao, Pedidos.IdCliente, Pedidos.vltotal1, Status_Pedidos.NmStatusPedido, " sqlCons = sqlCons & "Pedidos.IdRepresentante, Pedidos.DtFaturamento, Produtos.PtComissao,Pedidos.Idproduto, " sqlCons = sqlCons & "Pedidos.QdProduto, Pedidos.VlProduto FROM Pedidos, Produtos, Status_Pedidos" sqlCons = sqlCons & " Where Pedidos.CdTipoPagtoOP Is null AND Pedidos.Idproduto = Produtos.IdProduto AND Pedidos.CdStatusPedido = Status_Pedidos.CdStatusPedido"'Data do pedido... if Len(trim(DtPedidoIni)) > 0 and Len(trim(DtPedidoFim)) > 0 then         sqlCons = sqlCons & " AND Pedidos.DtPedido >=#"  & datamdy(DtPedidoIni)   sqlCons = sqlCons & "# AND Pedidos.DtPedido <=#" & datamdy(DtPedidoFim) & "#" end if 'Data de Finalização do pedido  if Len(trim(DtEntregaIni)) > 0 and Len(trim(DtEntregaFim)) > 0 then        sqlCons = sqlCons & " AND Pedidos.DtPedido >=#"  & datamdy(DtEntregaIni)   sqlCons = sqlCons & "# AND Pedidos.DtPedido <=#" & datamdy(DtEntregaFim) & "#" end if	 ' Inscrição do Representante... if idrepresentante <> 0 then sqlCons = sqlCons & " AND Pedidos.idrepresentante="& idrepresentante if idpedido        <> 0 then sqlCons = sqlCons & " AND Pedidos.idpedido="& idpedido sqlCons = sqlCons & " order by Pedidos."& ordenacaoelse sqlCons = "SELECT Pedidos.IdPedido, Pedidos.DtPedido, Pedidos.CdStatusPedido, Pedidos.DtFinalizacao, Pedidos.DtEntrega, Pedidos.IdCliente, " sqlCons = sqlCons & "Pedidos.vltotal1, Pedidos.QdProduto, Pedidos.VlProduto,  " sqlCons = sqlCons & "Pedidos.IdRepresentante, Pedidos.DtFaturamento, Produtos.PtComissao " sqlCons = sqlCons & "FROM Pedidos INNER JOIN Produtos " sqlCons = sqlCons & "ON Pedidos.Idproduto = Produtos.IdProduto " sqlCons = sqlCons & "where 1=1 AND Pedidos.idrepresentante=" &IdRepresentante if Len(trim(dtinicio)) > 0 and Len(trim(dtfim)) > 0 then  sqlCons = sqlCons & " AND Pedidos.DtEntrega <=#"& dtfim &"# " end if sqlCons = sqlCons & " AND not Pedidos.CdTipoPagtoOP > 0 "end if sqlX = "select count(*) as total FROM Pedidos" sqlX = sqlX & " Where CdTipoPagtoOP Is null " set rstemp=conntemp.execute( sqlX ) if not rstemp.eof then    total = rstemp("total") - 10 end if  set rstemp = nothing if VerificaAcesso(5) then%><script language="JavaScript" type="text/javascript">function teste(){   document.all.tmpessoal.value=document.all.idrepresentante.value;   //alert("document.all.idrepresentante.value"); }; function a(){ window.location ='tm061.asp?Acao=N&Vpessoal='+document.all.filtro.Vpessoal.value;};function selecionatodos(){  qtd = document.all.marca.length;  for (i = 0; i < qtd; i++) {    document.all.marca[i].checked = true;  };};function selecionainvertido(){  qtd = document.all.marca.length;  for (i = 0; i < qtd; i++) {    if (document.all.marca[i].checked){  document.all.marca[i].checked = false;	}else{  document.all.marca[i].checked = true;	}  };};function SelecionaFinalizados(){    var valor	qtd = document.all.marca.length;	for (i=0; i<qtd; i++) {   	 if(document.all.marca[i].checked){     valor = i;  } 	 }	for(x=0; x<valor; x++){  //alert("Testando Fora");  if(document.all.escondido+x.value==9){ 	 document.all.marca[x].checked=true; 	 alert("Testando");  }  alert(x);  //alert(document.all.escondido&(x).value);	}}function faturarpedidos(){ if (confirm("Confirma o Faturamento deste(s) pedido(s)?")) {  qtd           = document.all.marca.length;  // Caso haja um só item, o programa vai dar erro  if (qtd == null ) {   itensmarcados = document.all.marca.value;  } else {   itensmarcados = "";   contador      = 0;   for (i = 0; i < qtd; i++) {    if (document.all.marca[i].checked) {     contador = contador + 1;     if (contador!=1) { itensmarcados = itensmarcados + "," };     itensmarcados = itensmarcados + document.all.marca[i].value;    };   };  };  document.all.acaofaturar.value="D";  document.all.itens.value=itensmarcados;  if (itensmarcados == "" ) { alert("Selecione o(s) pedido(s) a ser(em) faturado(s).");}  else{ document.all.faturar.submit(); } };};function Atu_C(){ if (document.all.IdPedido.value > 0){  teste();  }; };function abrepedido( idped ) { window.open ("tm012.asp?IdPedido=" + idped, "blank","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=126,top=20,left=450")}; </script><html><head><title><%=titulo%></title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link href="inclusoes/cores.css" rel="stylesheet" type="text/css"><script language="javascript"  type="text/javascript">function ajustar_data(input){	if ((event.keyCode<48)||(event.keyCode>57)){  event.returnValue = false;   } else {   if ((input.value.length==2)||(input.value.length==5)) 	 input.value=input.value + "/";	};};</script></head><body onLoad="Javascript:Atu_C();" leftmargin="0" rightmargin="0" topmargin="0"><!--#include file="inclusoes/banner.asp" --><table width="780" border="0" cellpadding="0" cellspacing="0"> <tr>  <td>    <form action="tm061.asp" method="post" id="filtro" name="filtro" style="margin:0">        <table width="780" border="0" cellpadding="0" cellspacing="0" class="formulario">          <tr>             <td width="180" class="texto">Nº do Pedido:</td>            <td width="300" class="texto">Data de Pedido:</td>            <td width="300" class="texto">Data de Finalização</td>          </tr>          <tr>             <td class="texto"><input type="text" name="IdPedido" id="IdPedido"  value="<%=IdPedido%>" size="12" class="formulario"></td>            <td class="texto">De: <input type="text" name="DtPedidoIni" id="DtPedidoIni"  value="<%=DtPedidoIni%>" size="20" class="formulario" onKeyPress="ajustar_data(this)">              Até: <input type="text" name="DtPedidoFim" id="DtPedidoFim"  value="<%=DtPedidoFim%>" size="20" class="formulario" onKeyPress="ajustar_data(this)"></td>            <td class="texto">De:               <input type="text" name="DtEntregaIni2" id="DtEntregaIni2" value="<%=DtEntregaIni%>" size="20" class="formulario">              Até:                <input type="text" name="DtEntregaFim2" id="DtEntregaFim2" value="<%=DtEntregaFim%>" size="20" class="formulario">             </td>          </tr>          <tr>             <td width="60" class="texto" colspan="2">Revendedor:</td>            <td class="texto"></td>          </tr>          <tr>             <td class="texto" colspan="2"><select name="idrepresentante" class="formulario" style="width: 215px">          <%   	 sql = "Select * from pessoal where idtipopessoal<>4 "  if not administracao then sql = sql & " and idpessoal=" & idrepresentante  sql = sql & " order by nmfantasia"        set rstemp=conntemp.execute( sql )        TrataErro    'Contador de itens  ContaItem = 0          Do while not rstemp.eof 	 if len(rstemp("nmfantasia")) > 0 then          response.Write("<option value='" & rstemp("idpessoal") ) & "'"         if Trim(idrepresentante) = Trim(rstemp("idpessoal")) then response.Write(" selected ")         response.Write(">" & rstemp("nmfantasia") & "</option>")      else        response.Write("<option value='" & rstemp("idpessoal") ) & "'"         if Trim(idrepresentante) = Trim(rstemp("idpessoal")) then response.Write(" selected ")         response.Write(">" & rstemp("nmpessoal") & "</option>") 	  	 end if  	 rstemp.movenext 	  	 loop 	 set rstemp=nothing        %>       </select>                </b></font><%IF administracao = true THEN %>              Código:               <input type="text"  value="<%=Vpessoal%>" name="Vpessoal" id="Vpessoal2" class="formulario" size="10">          <input type="button" class="formulario" name="btnx" id="btnx" value="Busca" style="cursor:Hand; width:112" onClick="Javascript:a();" >  <%END IF%>            </td>            <td align="right" valign="bottom">             <img src="<%=base%>imagens/exibir.gif" alt="Exibir Consulta"              style="cursor: hand" onClick="Javascript:document.all.filtro.submit();">                </td>          </tr>        </table>    <input type="hidden" name="Acao" id="Acao" value="C">  </form>  </td> </tr> <tr>  <td> 	 <table width="780" border="0" cellpadding="0" cellspacing="0" class="texto" align="center">        <tr class="fundotit">           <td width="38"  height="18" class="menu3"> <b>Nº</b></td>          <td width="70" height="18" class="menu3"> <b>Dt.Pedido</b></td>          <td width="76" height="18" class="menu3"><b>Finalização</b></td>          <td width="72" height="18" class="menu3"> <b>Rev.</b></td>          <td width="122" class="menu3">Status</td>          <td width="152" height="18" class="menu3"> <b>Codigo/Descrição</b></td>          <td width="50" height="18" class="menu3" align="center"> <b>Qtde</b></td>          <td width="65" height="18" class="menu3" align="right"> <b>VL.             Unit.</b></td>          <td width="61"   height="18" class="menu3" align="right"> <b>VL.             Total </b></td>          <td width="64" height="18" class="menu3" align="right"><b>Faturar</b></td>          <td width="10"></td>        </tr>      </table>  <table cellpadding="0" cellspacing="0" border="0" width="780">    <tr>      <td>  <div id="Layer1" style="top: absolute; left: 0px; width: 780; height: 190; z-index: 1; overflow: auto; top: 220px">   <form action="tm024.asp" method="post" id="faturar" name="faturar" style="margin:0"> 	 <input type="hidden" name="itens" id="itens" value=""> 	 <input type="hidden" name="acao" id="acaofaturar">                <table border="0" width="713" cellpadding="0" cellspacing="0" class="texto">                  <%    set rstemp=conntemp.execute( sqlCons )    conta = 0    Do while not rstemp.eof  conta = conta + 1     'valor % comissao     VPC = (rstemp("ptcomissao") * ((rstemp("qdproduto")/1000) + rstemp("vlproduto"))) / 100     'controla data de faturamento     if len(rstemp("DtFaturamento")) > 0 then DTF = datadmy(rstemp("DtFaturamento")) else DTF = "-"    %>                  <tr style="cursor: hand" class="detalhe"     onmouseover="javascript:this.style.backgroundColor='#cccccc'"     onmouseout="javascript:this.style.backgroundColor=''">                     <td width="31" height="15" nowrap onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)">                        <%=rstemp("idpedido")%></td>                    <td width="50" height="15" nowrap onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)">                        <%=datadmy(rstemp("dtpedido"))%></td>                    <td width="50" height="15" nowrap onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)">                        <%=datadmy(rstemp("Dtfinalizacao"))%></td>                    <td width="50" height="15" nowrap title="<%     sql = "SELECT * from Pessoal Where IdPessoal= "& rstemp("idrepresentante")      set rstemp_R =conntemp.execute( sql )      'TrataErro   if not rstemp_R.eof then    if len(trim(rstemp_R("nmfantasia"))) > 0 then    response.Write rstemp_R("nmfantasia")  else 	 response.Write rstemp_R("nmpessoal")  end if     end if         set rstemp2=nothing         %>" onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)">                         <%     'pega nome do representante      sql = "SELECT * from Pessoal Where IdPessoal= "& rstemp("idrepresentante")      set rstemp_R =conntemp.execute( sql )      'TrataErro    if not rstemp_R.eof then      response.Write rstemp_R("Cdpessoal")	    end if         set rstemp2=nothing  %></td>                    <td width="140" nowrap title="<%     sql = "SELECT * from Pessoal Where IdPessoal= "& rstemp("idrepresentante")      set rstemp_R =conntemp.execute( sql )      'TrataErro   if not rstemp_R.eof then     if len(rstemp_R("nmfantasia"))>= 20 then      response.Write rstemp_R("nmfantasia")  end if    end if         set rstemp2=nothing         %>" onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)">     <%     if rsTemp("NmStatusPedido") = "expedido" then   	 response.Write("<font color='blue'>"&rsTemp("NmStatusPedido")&"</font>")    else   	 response.Write("<font color='red'>"&rsTemp("NmStatusPedido")&"</font>")	    end if    %>    </td>                    <td width="155" height="15" nowrap  title="<%     sqlp="SELECT Produtos.*, Pedidos.*, Pedidos.IdPedido "     sqlp = sqlp &"FROM Produtos INNER JOIN Pedidos ON Produtos.IdProduto = Pedidos.Idproduto "     sqlp = sqlp &"WHERE Pedidos.IdPedido="&rstemp("idpedido")     set rsp=conntemp.execute (sqlp)     if not rsp.eof then          response.Write(rsp("Cdproduto")&"/"&rsp("txidentificacao")&" "&rsp("VlAlturaProd")&"x"&rsp("VlLarguraProd")&" MM "&rsp("QdCelAlturaProd")&"/"&rsp("QdCelLarguraProd"))     end if      set rsp = nothing         %>" onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)">                        <%        sqlp="SELECT Produtos.*, Pedidos.*, Pedidos.IdPedido "        sqlp = sqlp &"FROM Produtos INNER JOIN Pedidos ON Produtos.IdProduto = Pedidos.Idproduto "        sqlp = sqlp &"WHERE Pedidos.IdPedido="&rstemp("idpedido")        set rsp=conntemp.execute (sqlp)        if not rsp.eof then           if len(rsp("Cdproduto")&"/"&rsp("txidentificacao")) > 22 then              response.Write(mid(rsp("Cdproduto")&"/"&replace(rsp("txidentificacao"),"""","'"),1,20)&"...")          else              response.Write(rsp("Cdproduto")&"/"&replace(rsp("txidentificacao"),"""","'"))          end if            end if         set rsp = nothing     %></td>                    <td width="54" height="15" align="center"          nowrap onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)"><%=rstemp("qdproduto")%></td>                    <td width="53" height="15"         align="center" nowrap onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)"><%=formatnumber(rstemp("vlproduto"))%></td>                    <td width="62" height="15"         align="center" nowrap onClick="Javascript: abrepedido(<%=rstemp("idpedido")%>)"><%=formatnumber(rstemp("vltotal1"))%></td>                    <td width="74" height="15" align="right" valign="top" title="" nowrap>                       <% 	 '#### ALTERADO POR MARCELO MENEZES - 02/12/04 ÀS 10:00 	 '#### if Cint(rstemp("CdstatusPedido")) <> 1 then 	 CdstatusPedido = Cint(rstemp("CdstatusPedido")) 	 if CdstatusPedido=3 or CdstatusPedido=4 or CdstatusPedido=9 then %> 	 <input size="1" align="top" type="checkbox" id="marca" name="marca" value="<%=rstemp("idpedido")%>" onClick="javascript: SelecionaFinalizados();"> 	 <input name="escondido<%=ContaItem%>" type="hidden" value="<%=CdstatusPedido%>" size="2">                        <%'=ContaItem%>                      <%           x=1 	 else    x=2 	 end if 	 %> </td>                  </tr>       <%    ContaItem = ContaItem+1           rstemp.movenext       loop    set rstemp = nothing       %>                </table>  </form> </div> 	 </td>    </tr>  </table>  <table width="780" border="0" cellspacing="0" cellpadding="0" class="menu3">   <% if conta = 0 then response.write "<tr><td height=18 colspan=4> </td></tr>" %>  <tr>	<TD class="fundotit"><%if (x = 1) and (total >= 1) then %> Falta <%=total%> pedidos para Fatura<%end if%></TD>   <td height="18" align="right" valign="middle" class="fundotit" colspan="5">    <% if (conta > 0) then  'and (x=1)%>    <img alt="Selecionar Todos" align="absmiddle" src="<%base%>imagens/selecionatodos.gif" border="0"     onClick="javascript: selecionatodos();" style="cursor: hand">    <img alt="Inverter Seleção" align="absmiddle" src="<%base%>imagens/selecionainvertido.gif" border="0"     onClick="javascript: selecionainvertido();" style="cursor: hand">    <img alt="Faturar Pedidos" align="absmiddle" src="<%base%>imagens/faturar.gif" border="0"     onClick="javascript: faturarpedidos();" style="cursor: hand">    <% end if %>   </td>  </tr> </table> </tr></table></body><% else %><!--#include file="inclusoes/naoautorizado.asp" --><% End If%><!--#include file="inclusoes/disconnect.asp" --></html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Cara na boa nuam tive paciência pra ler esse código todo...

 

mas você quer que selecione todas as Checkbox cujo o CDSTATUSPEDIDO seja =9

então, tenta assim

 

 

<input align="top" type="checkbox" id="marca" name="marca" value="<%=rstemp("idpedido")%>" <%if RS("CDSTATUSPEDIDO") = 9 then%>checked<%End if%>>

Naum sei se ajudei mas tai uma solução.

 

Flw B)

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.