When the user chooses a particular option in the select, another select will appear, that is, if the marital status is married, the conjugate appears.
I need the value of select to pass to a variable, this variable will communicate with the javascript and it will do the hide action insert the code here
window.onload = function exibir($pegavalor){
var valor = $pegavalor;
if(valor == true)
document.getElementById('optionOculto').style.display = "block";
else if(valor == false)
document.getElementById('optionOculto').style.display = "none";
};
};
}
<select name="civil" id="civil" onchange="exibir($pegavalor,'optionOculto')">
<option value="0"<?=($pegavalor = 0)?> >
-- Selecione --
</option>
<option value="1" <?=($pegavalor = 1)?> >
Casado
</option>
<option value="2" <?=($pegavalor = 0)?> >
Solteiro
</option>
<option value="3" <?=($pegavalor = 0)?> >
União Estável
</option>
<option value="4" <?=($pegavalor = 0)?> >
Divorciado
</option>
<option value="5" <?=($pegavalor = 0)?> >
Outros
</option>
</select>
<?php
echo $pegavalor;
if($pegavalor == 1){
$pegavalor = true;}
else{
$pegavalor = false;}
?>
<div id="optionOculto">
Nome Conjuge <input type="text" name="n-conjug"/>
Valor da Renda <input type="text" name="v-renda"/>
Outras Renda <input type="text" name="o-renda"/>
</div>