Jump to content


Photo

Ajuda Em Formulário[resolvido]


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

#1 Jorge Serrão

Jorge Serrão

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Não informado

Posted 05/05/2009, 10:02

Boas sou novo aqui no forúm portanto peço desculpa se o post não tiver ficado bem.

Eu estou a construir um site mais especificamente uma agenda onde insiro contactos.

Podem existir três tipos de contactos:
  • Profissionais
  • Pessoais
  • Emergência
E queria criar uma combobox em que aos escolher um deles aparecesse o respectivo formulário

Alguem me pode ajuda? Gostaria de fazer em JavaScript

Espero que me ajudem, obrigado

Edição feita por: Jorge Serrão, 12/05/2009, 06:54.


#2 Renan L. Queiroz

Renan L. Queiroz

    Mestre

  • Usuários
  • 690 posts
  • Sexo:Masculino
  • Localidade:Brasilia - DF

Posted 05/05/2009, 10:45

Aqui vai uma ajuda!

Adapte para o que vc necessita!
<html>
	<head>

		<title> Empresas </title>

		<script>

			function verificaEmpr(emp){

				var div = document.getElementById('div'+ emp.id);

				if (emp.checked == true)
					div.style.display = 'block';
				else
					div.style.display = 'none';
			}

		</script>

		<style>

			.cl_est{
				margin-top: 20px;
				margin-left: 50px;
				display: none;
			}

		</style>

	</head>

	<body>

		<form id="frm1" name="nm_frm1">

			<div>
				<input type="checkbox" id="ea" name="nm_ea" onClick="verificaEmpr(this);" />
				Empresa A
			</div>

			<div class="cl_est" id="divea">
				<input type="checkbox" id="a1" /> Estabelecimento A1 <br />
				<input type="checkbox" id="a2" /> Estabelecimento A2 <br />
				<input type="checkbox" id="a3" /> Estabelecimento A3 <br />
				<input type="checkbox" id="a4" /> Estabelecimento A4 <br />
			</div>

			<br />

			<div>
				<input type="checkbox" id="eb" name="nm_eb" onClick="verificaEmpr(this);" />
				Empresa B
			</div>

			<div class="cl_est" id="diveb">
				<input type="checkbox" id="b1" /> Estabelecimento B1 <br />
				<input type="checkbox" id="b2" /> Estabelecimento B2 <br />
				<input type="checkbox" id="b3" /> Estabelecimento B3 <br />
				<input type="checkbox" id="b4" /> Estabelecimento B4 <br />
			</div>

			<br />

			<div>
				<input type="checkbox" id="ec" name="nm_ec" onClick="verificaEmpr(this);" />
				Empresa C
			</div>

			<div class="cl_est" id="divec">
				<input type="checkbox" id="c1" /> Estabelecimento C1 <br />
				<input type="checkbox" id="c2" /> Estabelecimento C2 <br />
				<input type="checkbox" id="c3" /> Estabelecimento C3 <br />
				<input type="checkbox" id="c4" /> Estabelecimento C4 <br />
			</div>

		</form>

	</body>

</html>

Especialidade: Desenvolvimento e Banco de Dados.


Este post lhe ajudou? Agradeça: Posted Image


#3 Jorge Serrão

Jorge Serrão

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Não informado

Posted 05/05/2009, 11:52

Aqui vai uma ajuda!

Adapte para o que vc necessita!

<html>
	<head>

		<title> Empresas </title>

		&lt;script>

			function verificaEmpr(emp){

				var div = document.getElementById('div'+ emp.id);

				if (emp.checked == true)
					div.style.display = 'block';
				else
					div.style.display = 'none';
			}

		</script>

		<style>

			.cl_est{
				margin-top: 20px;
				margin-left: 50px;
				display: none;
			}

		</style>

	</head>

	<body>

		<form id="frm1" name="nm_frm1">

			<div>
				<input type="checkbox" id="ea" name="nm_ea" onClick="verificaEmpr(this);" />
				Empresa A
			</div>

			<div class="cl_est" id="divea">
				<input type="checkbox" id="a1" /> Estabelecimento A1 <br />
				<input type="checkbox" id="a2" /> Estabelecimento A2 <br />
				<input type="checkbox" id="a3" /> Estabelecimento A3 <br />
				<input type="checkbox" id="a4" /> Estabelecimento A4 <br />
			</div>

			<br />

			<div>
				<input type="checkbox" id="eb" name="nm_eb" onClick="verificaEmpr(this);" />
				Empresa B
			</div>

			<div class="cl_est" id="diveb">
				<input type="checkbox" id="b1" /> Estabelecimento B1 <br />
				<input type="checkbox" id="b2" /> Estabelecimento B2 <br />
				<input type="checkbox" id="b3" /> Estabelecimento B3 <br />
				<input type="checkbox" id="b4" /> Estabelecimento B4 <br />
			</div>

			<br />

			<div>
				<input type="checkbox" id="ec" name="nm_ec" onClick="verificaEmpr(this);" />
				Empresa C
			</div>

			<div class="cl_est" id="divec">
				<input type="checkbox" id="c1" /> Estabelecimento C1 <br />
				<input type="checkbox" id="c2" /> Estabelecimento C2 <br />
				<input type="checkbox" id="c3" /> Estabelecimento C3 <br />
				<input type="checkbox" id="c4" /> Estabelecimento C4 <br />
			</div>

		</form>

	</body>

</html>



Muito Obrigado pela ajudinha.

Resolveu o meu Problema




1 user(s) are reading this topic

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

IPB Skin By Virteq