Ir para conteúdo

Arquivado

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

mayhem

Criar botões radio para dois formulários diferentes

Recommended Posts

Bom dia, sou novato na area,  e preciso criar dois formulários, quando a pesso habilitar o botão radio de PF terá que aparecer os campos para PF, e quando selecionado PJ, mostrar os campos especificos para PJ, como é possivel fazer isso?


  <form name ='"lol">
  
  <input type="radio" name="parcelamento" id="parcelamento" style="width:15px; height:15px" value="PF" onclick="exibeOutros()">Pessoa Fisíca </input>
    <input type="radio" name="parcelamento" id="parcelamento" style="width:15px; height:15px" value="PJ" onclick="exibeOutros()"> Pessoa Jurídica </input>
  
            <fieldset>
                <label for="nm">Nome :</label>
                <input required name="nm" size ="46" onclick="tipo()">
                <label for="cpf">CPF:</label>
                <input required name="cpf" size ="56"> <p>
                <label for="Bairro">Bairro:</label>
                <input required name="bairro" size ="15">
                <label for="cep">CEP:</label>
                <input required name="cep" size="8">

</fieldset>

 

  <fieldset>
                <label for="em">Empresa :</label>
                <input required name="em" size ="46"">
                <label for="cnpj">CNPJ</label>
                <input required name="cnpj" size ="56"> <p>
                <label for="end">Endereco:</label>
                <input required name="end" size ="15">
                <label for="dir">Diretor:</label>
                <input required name="dir" size="8">

</fieldset>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

display: none;

e

display: block;

 

ai você controla caso selecione uma coisa, none em um e block no outro

Compartilhar este post


Link para o post
Compartilhar em outros sites

Este código não deveria funcionar?

function exibeOutros() == null{{
document.getElementById('pessoa').disabled=true
document.getElementById('juridica').disabled=true
} if else exibeOutros() == 'PF' {
document.getElementById('pessoa').disabled=false
document.getElementById('juridica').disabled=true
} else {
document.getElementById('pessoa').disabled=true
document.getElementById('juridica').disabled=false
}}    

Compartilhar este post


Link para o post
Compartilhar em outros sites

não, tem erro de sintaxe e de lógica ai.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Consegui fazer desta maneira 

  <b><input type="radio" name="parcelamento" id="parcelamento" style="width:15px; height:15px" value="PF" onclick="exibeOutros(true)">Pessoa Fisíca </input>
     <input type="radio" name="parcelamento" id="parcelamento" style="width:15px; height:15px" value="PJ" onclick="exibeOutros(false)"> Pessoa Jurídica </input> <p>
<script language="javascript">
function exibeOutros(bool)
{

if (bool) {
document.getElementById("pessoa").style.display = "";
document.getElementById("juridica").style.display = "none";
} else {
document.getElementById("pessoa").style.display = "none";
document.getElementById("juridica").style.display = "";
}

}

 

só preciso desabilitar os dois ao entrar na página.

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.