Ajuda Com Campo Select

5 respostas
D

Fala Galera,

Estou com um problema e gostaria de uma ajuda. É o seguinte, eu tenho um campo que seleciona algumas gerencias no meu sistema. Eu quero que ao clicar em um gerencia especifica aparece mais 2 campos text, estou tentando usar um

e no select chamo uma fuction onclick=“exibe()” mais não consigo fazer aparecer. Alguem pode me ajudar?
<tr>
    <td> 
        <select size="1" name="selecione" id="selecione" style="font-size: 8pt; font-family: Verdana; color: #006699">
		<option value="0">Selecione</option>
		<option value="Assessoria da Presidência" >Assessoria da Presidência</option>
		<option value="Gerência Jurídica" onclick="exibe()">Gerência Jurídica</option>
		<option value="Gerência de Cadastro e Contribuições" >Gerência de Cadastro e Contribuições</option>
	</select>
     </td>
 </tr>
<tr>
   <td>
      <div id="div1" style="display:none" >
	<table border="0" width="100%" cellspacing="1" cellpadding="0">
		<tr>										  				
		   <td>                                                
			<font face="Tahoma" style="font-size: 8pt" color="#333333">Nº/ano do processo:</font></td>
	 	</tr>
		<tr>
		    <td><font size="1" color="#000000">
		    <input name="numeroAno" id="numeroAno" type="text" style="font-family: Verdana; font-size: 8pt; color: #006699" size="15" maxlength="11" maxlength="9" onkeypress="return txtBoxFormat(this,'9999/9999', event);return SoNum();" onChange="Preenche2();"></font></td>
		</tr>		
		<tr>
		   <td>                                                
		      <font face="Tahoma" style="font-size: 8pt" color="#333333"> 
			Espécie do Benefício/plano:</font></td>
		</tr>
		<tr>
		   <td><font size="1" color="#000000">
		   <input name="especiePlano" id="especiePlano" type="text" style="font-family: Verdana; font-size: 8pt; color: #006699" size="15" maxlength="11" maxlength="9" onkeypress="return txtBoxFormat(this,'9999/9999', event);return SoNum();" onChange="Preenche2();"></font></td>
		</tr>											  		
	 </table>
        </div>
     </td>										  	
 </tr>

5 Respostas

D

Esqueci do java script

function exibe(){
		alert("entrou");
	    if (document.getElementById("div1").style.display == 'none')
	        document.getElementById("div1").style.display = 'block';	   
	}
		
	function naoExibe(){
        document.getElementById("div1").style.display = 'none';
	}
Natalia_Lima

Então…
Ao invés de usar o onclick no option, usa o onchange no select…

Aí vc testa o Value do option, que aí funfa!

Natalia_Lima

Não sei é isso que vc quer, mas desse jeito aí funciona

<html>
<body>

<table>

<tr>
    <td> 
        <select size="1" name="selecione" id="selecione" style="font-size: 8pt; font-family: Verdana; color: #006699" onchange="exibe()">
		<option value="0">Selecione</option>
		<option value="Assessoria da Presidência" >Assessoria da Presidência</option>
		<option value="Gerência Jurídica">Gerência Jurídica</option>
		<option value="Gerência de Cadastro e Contribuições" >Gerência de Cadastro e Contribuições</option>
	</select>
     </td>
 </tr>
<tr>
   <td>
      <div id="div1" style="display:none" >
	<table border="0" width="100%" cellspacing="1" cellpadding="0">
		<tr>										  				
		   <td>                                                
			<font face="Tahoma" style="font-size: 8pt" color="#333333">Nº/ano do processo:</font></td>
	 	</tr>
		<tr>
		    <td><font size="1" color="#000000">
		    <input name="numeroAno" id="numeroAno" type="text" style="font-family: Verdana; font-size: 8pt; color: #006699" size="15" maxlength="11" maxlength="9" onkeypress="return txtBoxFormat(this,'9999/9999', event);return SoNum();" onChange="Preenche2();"></font></td>
		</tr>		
		<tr>
		   <td>                                                
		      <font face="Tahoma" style="font-size: 8pt" color="#333333"> 
			Espécie do Benefício/plano:</font></td>
		</tr>
		<tr>
		   <td><font size="1" color="#000000">
		   <input name="especiePlano" id="especiePlano" type="text" style="font-family: Verdana; font-size: 8pt; color: #006699" size="15" maxlength="11" maxlength="9" onkeypress="return txtBoxFormat(this,'9999/9999', event);return SoNum();" onChange="Preenche2();"></font></td>
		</tr>											  		
	 </table>
        </div>
     </td>										  	
 </tr>	

</table>

</body>
</html>

<script language="Javascript">

	function exibe(){
		if (document.getElementById("selecione").value == "Gerência Jurídica")
	        document.getElementById("div1").style.display = 'block';
		else			{
			document.getElementById("div1").style.display = 'none';
		}
	}
		
	

</script>
D

Funcionou!!! Muito Obrigado Natalia!!!

Natalia_Lima

Beleza! :lol:

Criado 10 de agosto de 2010
Ultima resposta 10 de ago. de 2010
Respostas 5
Participantes 2