Ir para conteúdo

Arquivado

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

alexjose123

no select

Recommended Posts

Senhores peço auxilio em encontrar o erro neste código abaixo.

A função dele é ocultar um div = "conjulge" ou exibi-la conforme a

escolha no select.

 

 


<script type="text/javascript">

	alert("1");
	$(document).ready(function(){
	alert("2");
		$('#conjulgue').hide();


	});

	function habilitaCampos(par){
		alert("3");
  	$('#conjulgue').show();
	}			

</script>


</head>

<body>


<select  name="estadocivil" id="estadocivil" >
	<option value="0" >Selecione</option>
	<option value="1" onchange="habilitaCampos('nao');">Solteiro(a)</option>
	<option value="2" ondblclick="habilitaCampos('sim');">Casado(a)</option>
	<option value="3" onchange="habilitaCampos('nao');">Desquitado(a)</option>
	<option value="4" onchange="habilitaCampos('nao');">Viuvo(a)</option>
	<option value="5" onchange="habilitaCampos('nao');">Separado(a) Judicial</option>
	<option value="6" onchange="habilitaCampos('nao');">Companheiro(a)</option>
	<option value="7" onchange="habilitaCampos('nao');">Divorciado(a)</option>
	<option value="8" onchange="habilitaCampos('nao');">Outros</option>
</select>
	<option value="9" onchange="habilitaCampos('nao');">Não Informado</option>


    <div id="conjulgue" name="conjulgue" >
			<dl>
					<dt><label for="profissao">Nome do Conjulgue:</label></dt>
					<dd><input type="text" name="nomeconjulgue" id="nomeconjulgue" size="52" maxlength="50" /></dd>
			</dl>

			<dl>
					<dt><label for="profissao">CPF do conjulgue:</label></dt>
					<dd><input type="text" name="cpfconjulgue" id="cpfconjulgue" size="13" maxlength="11" /></dd>
			</dl>

			<dl>
					<dt><label for="profissao">RG do conjulgue:</label></dt>
					<dd><input type="text" name="rgconjulgue" id="rgconjulgue" size="11" maxlength="9" /></dd>
			</dl>

			<dl>
				<dt><label for="orgaoexpedidor">Orgão Expedidor:</label></dt>
				<dd><input type="text" name="orgaoexpedidorconjugue" id="orgaoexpedidorconjulgue" size="3" maxlength="5" /></dd>  	
			</dl>
			<dl>

</div>

</body>


</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

function habilitaCampos(par){
       if( par=='sim' )
               $('#conjulgue').show();
       else $('#conjulgue').hide();
} 

 

você recebeu um argumento mas num fez nada com ele..

 

além doq, não existe evento na tag <option>

você deve usar um onchange no <select>, e testar o valor escolhido na tua função.

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.