Jump to content


Photo

Valor Não é Enviado


  • Faça o login para participar
2 replies to this topic

#1 ** Arena Jovem **

** Arena Jovem **

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Masculino
  • Localidade:curitiba

Posted 15/12/2008, 13:55

Boa tarde galera.

Bom tenho um form, nele contem um checkbox , o value dele e 1

tenho tbm a pagina que recebe ele

ai logo quando recebo tenho q fazer uma comparaçao

se cke1 for diferente que 1 entao
test=1
caso contrario
test=0

logo em seguida tenho que inserir os dados no banco

mas quando tento postar a ele passa o value do checkbox vazio..


form
<form name="teste" action="adm_gestor_inc2.asp"  method="post" enctype="multipart/form-data" >
<input name="per_tutoria" type="checkbox" value="">
<input type="submit">
</form>

pagina que recebe
dim sql
dim per_tutoria

dim Upload, fsPasta, Diretorio_Publica, Diretorio_Temp, count


' EFETIVA A GRAVAÇÃO EM BANCO
sql ="insert into usuario (cod_perfil_usuario, "&_
		"usu_gestor_perm_tutor, "&_

sql = sql & "values (" & perfil & ", " &_
"'" & Ucase(per_tutoria) & "'


fx_Open rssql, sql, 1, 1, 1
	fx_Close rssql



alguem ai pode me dar uma mao ai??

agradeçodesde ja!!

#2 Alex Hiroshi

Alex Hiroshi

    Super Veterano

  • Ex-Admins
  • 4923 posts
  • Sexo:Masculino
  • Localidade:São Paulo - SP

Posted 15/12/2008, 14:20

Está passando vazio porque você não colocou um value no checkbox. Deixe com um valor padrão - 1, por exemplo. Na parte do asp você só verifica se ele existe ou se é 1.
Fórum WMO - Equipe de Desenvolvimento / Banco de Dados - Ex-Administrador

#3 ** Arena Jovem **

** Arena Jovem **

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Masculino
  • Localidade:curitiba

Posted 15/12/2008, 15:27

Está passando vazio porque você não colocou um value no checkbox. Deixe com um valor padrão - 1, por exemplo. Na parte do asp você só verifica se ele existe ou se é 1.



na verdade meu codigo e o seguinte.

e meio complexo...
form
<!--#include virtual="/includes/lms_top.asp"-->
<%


' -------------------------------------------------------------------------------------------------
' CONFIGURAÇÃO DA TAG <BODY>
' Definição das constantes

	const ind_exibicao_img_background 	= false				'Exibe a imagem padrão do módulo em background.
	const ind_menu_contexto 			= false				'Habilita o MENU DE CONTEXTO.
	const ind_onhelp 					= true				'Habilita F1 para AJUDA PERSONALIZADA.
	const str_onload 					= ""				'Ex.: Iniciar(); return false;
	const str_onunload 					= ""				'Ex.: Reload(); return true;

	dim str_adicional 'TAGS adicionais
	str_adicional = ""



' -------------------------------------------------------------------------------------------------
' APRESENTAÇÃO DO CONTEÚDO

	'Lista Cargos
'	sql_perfil = "Select * from Lms_Perfil_Usuario where cod_perfil_usuario<>6 order by des_perfil_usuario"
'	fx_open rs_perfil, sql_perfil, 1, 1, 1


%>

&lt;script language="javascript">
	function mostrarFoto(caminho)
	{
		if (caminho.replace(' ', '') != '')
		{
			caminho = caminho.replace('\\', '\\\\');
			document.frmInclusaoGestores.fotoView.src = caminho;
		}
		
	}
	
</script>


<!--#include virtual="/includes/lms_body.asp"-->

		<!-- CONTEÚDO return v.exec() -->
	<form ID="frmInclusaoGestores" name="frmDados" action="adm_gestor_inc2.asp"  method="post" enctype="multipart/form-data" >
	<table width="736" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="736" height="32" valign="top"><img src="/images/titulos/tit_gestores.jpg" width="375" height="32"></td>
		  </tr>
		  <tr>
			<td width="736" height="1" valign="top"><img src="/images/layout/linha_interna.jpg" width="736" height="1"></td>
		  </tr>
		  <tr>
			<td width="736" height="5" valign="top"><img src="/images/layout/spacer.gif" width="736" height="5"></td>
		  </tr>
		  <tr>
			<td>
			  <table height="317" cellSpacing=0 cellPadding=5 width=720 align=center bgColor=#ffffff border=0>
				<tbody>
				  <tr>
					<td vAlign=top>
					<table width="390" height="386" cellpadding="0" cellspacing="0" class="td_janela_full">
					  <tr>
						<td class="td_janela_titulo_full">Cadastro de Gestores </td>
					  </tr>
					   <tr>
					<td width="710" valign="top" style="padding-left:15;padding-right:15;padding-top:10;padding-bottom:10">							
					<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
					  <tr> 
					  <td width="80"> 
						  <table width="80" border="0" cellspacing="0" cellpadding="0" class="input_botao">
							<tr onClick="java script:history.back();" onMouseOver="this.className='input_botao_sel';" onMouseOut="this.className='input_botao';"> 
							  <td width="25" height="25" align="center"><img src="/images/icones/ico_16x16_voltar.gif" width="16" height="16"></td>
							  <td>Retornar</td>
							</tr>
						  </table>
						</td>
						<td width="1"> </td>
						<td width="80"> <table width="80" border="0" cellpadding="0" cellspacing="0" class="input_botao">
							<tr  onClick="java script:Verifica();"  onmouseover="this.className='input_botao_sel';" onMouseOut="this.className='input_botao';"> 
							  <td width="25" height="25" align="center"><img src="/images/icones/ico_16x16_atualizar.gif" width="16" height="16"></td>
							  <td>Gravar</td>
							</tr>
						  </table></td>
						
						<td width="1"> </td>
						<td width="80">
						<table width="80" border="0" cellspacing="0" cellpadding="0" class="input_botao">
							<tr onClick="java script:frmInclusaoGestores.reset();document.frmInclusaoGestores.fotoView.src = document.frmInclusaoGestores.fotoOrigem.value;" onMouseOver="this.className='input_botao_sel';" onMouseOut="this.className='input_botao';"> 
							  <td width="25" height="25" align="center"><img src="/images/icones/ico_16x16_limpar.gif" width="16" height="16"></td>
							  <td>Limpar</td>
							</tr>
						  </table>
						</td>
						<td width="100%">  </td>
					  </tr>
					</table>					  
					<br><br><br>
					
					<input type="hidden" name="fotoOrigem" id="fotoOrigem" value="\images\fotos_usuarios\no_foto.gif">
					<input type="hidden" name="unidadeSelecionada" id="unidadeSelecionada" value="">
					  <table width="100%" border='1' cellspacing='0' cellpadding='2' bordercolor="#EEEEEE" style="border: 2px solid #DFDFDF">
						<tr>
						  <td height="25">
							
							  <table width="100%"  border="0" cellspacing="0">
							  <br>
								<tr>
								  <td width="63" rowspan="7"><img src="\images\icones\no_foto.gif" border="0" id="fotoView" name="fotoView" width="60" height="70"  /></td>
								  <td width="90" height="28" id="t_nome">  Nome: [*]</td>								  
								  <td colspan="4"><input id="nome" name="nome" type="text" size="60" maxlength="50" class="input_texto">
								   <% call fx_Ajuda_Form ("usuario","usu_nome","Nome") %></td>
								</tr>
								<tr>
								  <td width="90" height="28" name="t_login" id="t_login">  Login: [*]</td>
								  <td colspan="2"><input id="login" name="login" type="text" size="16" maxlength="16" class="input_texto">
								  <% call fx_Ajuda_Form ("usuario","usu_id","Login") %>								  </td>
								   <td width="62" height="28" id="t_senha" name="t_senha">  Senha: [*]</td>
								   <td width="194" ><input id="senha" name="senha" type="password" size="12"  class="input_texto">
								  <% call fx_Ajuda_Form ("usuario","usu_cadastro","Senha") %>								   </td>								  
								</tr>
								 <tr>								 
								  <td width="90" height="28" id="t_unidade" name="t_unidade">  Unidade: [*]</td>
								  <td width="211" onClick="fx_Popup('../../_compartilhado/unidade.asp', 'nome', 'scroll=auto', '400', '350', 'true')" style="cursor:hand">
								  <input id="unidade" name="unidade" type="text" size="30" maxlength="38" class="input_texto">
								  <img onClick="fx_Popup('../../_compartilhado/unidade.asp', 'nome', 'scroll=auto', '400', '350', 'true')" style="cursor:hand" src="/images/icones/home.gif"></td>

								  <td width="38"> <% call fx_Ajuda_Form ("usuario","uni_codigo","Nome") %></td>

								   <td width="62" id="t_cargo">Cargo:</td>
								   	<td valign="baseline" >
										<iframe src="cargo_seleciona.asp" id="selecionaCargo" name="selecionaCargo" width="182px" height="30px"></iframe></select>
										<input type="hidden" name="car_codigo" id="car_codigo">								   </td>
								</tr>

								<tr>
								  <td width="90" height="28" id="t_foto" name="t_foto">  Foto: [*] </td>
								  <td colspan="4"><input onFocus="mostrarFoto(this.value)" id="foto" name="foto" type="file" size="50" maxlength="50" class="input_texto">								  
								   <% call fx_Ajuda_Form ("usuario","usu_arquivo_foto","Foto") %>								  </td>								  
								</tr>
								<tr>
								   <td width="90" height="28" id="t_email" name="t_email">  E-mail:</td>
								   <td width="211" ><input id="email" name="email" type="text" size="40" maxlength="50" class="input_texto"></td>
								   <td width="38"> <% call fx_Ajuda_Form ("usuario","uni_codigo","Nome") %></td>
								  <td colspan="3">  Email Ativo: 		
									   <select id="emailativo" name="emailativo">	
									   		<option value="0">Caixa Postal</option>
											<option value="1">Email externo</option>
											<option value="2">Ambos</option>
									   </select>
									   <% call fx_Ajuda_Form ("usuario","usu_email_ativo","Email Ativo") %>								  </td>
								</tr>
								
								<tr>
								  <td colspan="2"></td>
								</tr>
								
								<tr>
								  <td width="90" height="28">  Data de Nascimento:</td>
									<td width="211" ><input id="data" name="data" type="text" size="20" maxlength="20" class="input_texto">
								  <% call fx_Ajuda_Form ("usuario","usu_data_nascimento","Data de Nascimento") %>								  </td>
								  <td width="38"> </td>
								  
								  <td width="62" height="28">  Telefone:</td>
								  <td width="194"><input id="Text1" name="telefone" type="text" size="20" maxlength="20" class="input_texto">
								   <% call fx_Ajuda_Form ("usuario","usu_telefone","Telefone") %>								  </td>
								</tr>
								
								<tr>								
								  <td> </td>								  
								  <td>Permissão Tutoria </td>
								  <td> 
								   <input name="per_tutoria" type="checkbox" value=""></td>
								 <% call fx_Ajuda_Form ("usuario","per_tutoria","Permissao Tutoria") %>
								  <td> </td>
								  <td> </td>
								  <td> </td>
								</tr>
								<tr>
								  <td colspan="6">[*] Campo de preenchimento obrigatório</td>
								</tr>
							</table>
						  </td>
						</tr>
					  </table>
					 
					  </td>
					   </tr>
					  <tr>
						<td class="td_janela_bot_full"></td>
					  </tr>
					</table>
					</td>
				  </tr>
				</tbody>
			</table></td>
		  </tr>
		</table>
		 </form>
		
		
&lt;script language="JavaScript1.2" type="text/javascript">

//	document.frmInclusaoTutores.nome.focus();
//	var a_fields = {'nome':		{'l':'Nome',		'r':true,	'f':'texto',	't':'t_nome','mn':3,'mx':60},
//					'login':	{'l':'Login',		'r':true,	'f':'texto',	't':'t_login','mn':2,'mx':60},
//					'senha':	{'l':'Senha',		'r':true,	'f':'texto',	't':'t_senha','mn':2,'mx':60},
//					'unidade':	{'l':'Unidade',		'r':true,	'f':'texto',	't':'t_unidade','mn':2,'mx':60}},										
					//'foto':		{'l':'Foto',		'r':true,	'f':'texto',	't':'t_foto','mn':2,'mx':300}},

//		o_config = {'to_disable' : ['Submit', 'Reset'],'alert' : 1}

//	var v = new validator('frmInclusaoTutores', a_fields, o_config);
	
//function Send()
//{
//	document.frmInclusaoTutores.target='';
//	document.frmInclusaoTutores.action='adm_tutor_inc2.asp';
//	return v.exec();
	
//}	
	function Verifica()
	{		
		if(document.getElementById('nome').value== ""){
			alert('O campo Nome é de preenchimento obrigatório!');
			return;
		} 
		if(document.getElementById('login').value== ""){
			alert('O campo Login é de preenchimento obrigatório!');
			return;
		} 
		if(document.getElementById('senha').value== ""){
			alert('O campo Senha é de preenchimento obrigatório!');
			return;
		} 
		if(document.getElementById('unidade').value== ""){
			alert('É necessário que  Unidade seja selecionada!');
			return;
		} 
		if(document.getElementById('unidade').value== ""){
			alert('É necessário que  Unidade seja selecionada!');
			return;
		}
		
		document.getElementById('frmInclusaoGestores').submit();
			
	}
</SCRIPT>
	<!-- FIM CONTEÚDO -->
<!--#include virtual="/includes/lms_bot.asp"-->
<%
' -------------------------------------------------------------------------------------------------
' CÓDIGO COMPLEMENTAR
' Executado após a apresentação do conteúdo.


%>

pagina que grava os dados no banco

<!--#include virtual="/includes/lms_top.asp"-->
<!--#include virtual="/scripts/funcoes.asp"-->


<%
  
dim sql
dim cargo, perfil, nome, login, telefone, email , data 
dim foto , codigoCadastrador , unidadeSelecionada , cliente , emailativo , per_tutoria
dim Upload, fsPasta, Diretorio_Publica, Diretorio_Temp, count

Set Upload = Server.CreateObject("Persits.Upload.1")
Set fsPasta = Server.CreateObject("Scripting.FileSystemObject")
Diretorio_Publica = Server.MapPath("/images/fotos_usuarios/")
Diretorio_Temp = Server.MapPath("/images/galeria/publica/temp/")
a=request("nome")
response.Write(a)

'é necessário salvar o arquivo antes de recuperar os dados da tela anterior.
count = Upload.Save(Diretorio_Temp)	

'----------------------------------- RECUPERA DADOS DO FORM -------------------------------------------

	For Each Item in Upload.Form		
		if Item.Name = "nome" then
			nome = Item.Value
		end if
		if Item.Name = "login" then
			login = Item.Value
		end if
		if Item.Name = "senha" then
			senha = Item.Value
		end if
		if Item.Name = "email" then			
				email=Item.Value						
		end if  
		if Item.Name = "data" then
			data = Item.Value
			data = FormataDataUSA(data)
		end if
		if Item.Name = "foto" then
			foto = Item.Value
		end if
		if Item.Name = "emailativo" then
			emailativo = Item.Value				
		end if
		if Item.Name = "car_codigo" then
			car_codigo = Item.Value
		end if
		if Item.Name = "unidadeSelecionada" then
			uni_codigo = Item.Value
		end if
	Next
	
	for each File in Upload.Files
	if File.Name = "foto" then
			foto = File.ExtractFileName
		end if	
	next

	'PERFIL DE GESTOR
	perfil = 3
	'Variavel utilizada para ver se a gravação da foto ocorreu corretamente
	frmOK = true

	
	'Codigo de quem esta logado
	codigoCadastrador = Session("usuario_codigo")
	'Codigo do cliente logado
	strSQL = "SELECT cli_codigo, uni_codigo, uni_codigo_pai FROM Unidade WHERE uni_codigo = " & uni_codigo
	fx_Open rsUnidadeTutoria, strSQL, 1, 1, 1

	cli_codigo = rsUnidadeTutoria("cli_codigo")
	uni_codigo  = rsUnidadeTutoria("uni_codigo")
	uni_codigo_pai = rsUnidadeTutoria("uni_codigo_pai")
	fx_Close rsUnidadeTutoria
	
' -----------------------------------------------------------------------------------------------------

	if foto <> "" then
		For Each File in Upload.Files
		
			if UCASE(File.Ext) <> ".JPG" and UCASE(File.Ext) <> ".GIF" then
				File.Delete
				Response.Write("&lt;script LANGUAGE=""javascript\""> ")
				Response.Write("alert('O arquivo não é compatível com o tipo de arquivo selecionado.\n\nSão aceitos apenas .GIF e .JPG'); ")
				Response.Write("window.history.go(-1); ")
				Response.Write("</SCRIPT> ")
				frmOK = false
			end if
		
			Tamanho = File.Size
			if Tamanho > 1048576 then 'tamanho de arquivo fixo em 1mb
				
				File.Delete
				
				Response.Write("&lt;script LANGUAGE=""javascript\""> ")'Response.Write("<!-- ")
				Response.Write("alert('O arquivo deve ter no máximo 1Mb!'); ")
				Response.Write("window.history.go(-1); ")
				'Response.Write("//--> ")
				Response.Write("</SCRIPT> ")
				frmOK = false
			End If
			
				if fsPasta.FileExists(Diretorio_Publica & "\" & File.ExtractFileName) then
				File.Delete
				Response.Write("&lt;script LANGUAGE=""javascript\""> ")'Response.Write("<!-- ")
				Response.Write("alert('Já existe um arquivo com este nome em uma galeria!'); ")
				Response.Write("window.history.go(-1); ")
				Response.Write("</SCRIPT> ")	
				frmOK = false
			end if
				
			if frmOK then
				File.Move Diretorio_Publica & "\" & File.ExtractFileName
				Imagem = File.ExtractFileName
			end if
		next
			
		' GERA O THUMB DA IMAGEM
		if frmOK then
			call fx_Thumb( Imagem, Diretorio_Publica, Diretorio_Publica & "\small\", true, 80, 90 )
		end if
	end if
						   

if 	frmOK then
	' EFETIVA A GRAVAÇÃO EM BANCO
	sql =	"insert into usuario (cod_perfil_usuario, "&_
			"usu_nome, "&_
			"usu_id, "&_
			"usu_telefone, "&_
			"usu_email, "&_
			"usu_data_nascimento, "&_
			"usu_cadastro, "&_
			"usu_arquivo_foto, "&_
			"usu_cod_cadastrador, "&_
			"uni_codigo, "&_
			"uni_codigo_principal, "&_
			"cli_codigo, "&_
			"usu_ind_exclusao, "&_
			"usu_email_ativo, "&_
			"usu_gestor_perm_tutor, "&_
			"usu_online, " &_
			"car_codigo) "
	sql = sql & "values (" & perfil & ", " &_
			"'" & Ucase(nome) & "', "&_
			"'" & login & "', "&_
			"'" &telefone & "', "&_
			"'" & email & "', "&_
			"" & data & ", "&_
			"'" & senha & "', "&_
			"'" & foto & "', "&_
			"'" & codigoCadastrador & "', "&_
			"'" & uni_codigo & "', "&_
			"'" & uni_codigo_pai & "', " &_
			"'" & cli_codigo & "', " &_
			"'0', " &_
			"'" & emailativo & "', " &_
			response.Write(per_tutoria)	&_
			"'" & per_tutoria & "', " &_
			"'0', " &_
			"'" & car_codigo &"')"			

	fx_Open rssql, sql, 1, 1, 1
	fx_Close rssql
	
	sql = "select max(usu_codigo) as usu_codigo from usuario"
	fx_Open rsMax, sql, 1, 1, 1
	usu_codigo = rsMax("usu_codigo")
	fx_Close rsMax
	
	sql = "Insert into usuario_unidade (usu_codigo, uni_codigo) " &_
		  "Values (" & usu_codigo & ", " & uni_codigo & ")"
	fx_Open rsUniUsu, sql, 1, 1, 1	
	fx_Close rsUniUsu 
		
	response.redirect "adm_gestor_inc.asp"
end if

%>
<!--#include virtual="/includes/lms_bot.asp"-->


assim acho q fica mais facil de ver com meu forme completo e a pagina que recebe ele.




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq