0
I would like some help on element style.display in java script. JS is not changing a div declared in None jsp to block. I have a jsp page that has a div of the hidden type:
<input type="radio" id="ContaForm" name="nuTipoContaR" value="1" checked/> Conta raíz
<input type="radio" id="ContaForm" name="nuTipoContaE" value="2"/> Estrangeira
<br>
</div>
<div id="divInstituicao" style="display:none;">
<div id="divInstituicaoEstrangeira" style="display:none;">
<div class="divlinha">
<div class="linhaLabel"> Instituição:</div>
<div class="divlinhaLabelTexto">
<html:text property="instituicaoEstrangeira" styleId="instituicaoEstrangeira" value="" onkeypress='return trataEnterAspas( event );' onblur="trataCaracteres( this );" onkeyup="trataCaracteres( this );" maxlength="60" size="78" /> <br />
</div>
</div>
</div>
</div>
In javascript my intention is to check if the div is None and if the radiobutton is clicked , display this div. But not going, he even recognizes that the div is None , but in Document.Elementbyid("institution").style.display="block" the system does not display the div on the jsp screen. Please help me, I’m a beginner and I’ve done some research, but without success.
$('#form input:radio').bind("click", function() {
if ($(this).is(':checked')) {
var tipoTce = $("input[@name='ContaForm']:checked").value;
tipoConta = parseInt($(this).val());
if(tipoConta == "2"){
var deConta = $("#deContaEstrangeira").val();
var nuContaEstranegira = $("#nuContaEstrangeira").val();
var noContaEstrangeira = $("#noContaEstrangeira").val();
document.getElementById("descMotivo").innerHTML = deMotConta;
document.getElementById("noTipoConta1").value = noContaEstrangeira;
document.getElementById("deTipoConta1").value = deMotConta;
document.getElementById("nuTipoConta1").value = nuContaEstrangeira;
if(document.getElementById("divInstituicao").style.display == "none"){
document.getElementById("divInstituicao").style.display = "block";
}
}
else if(tipoConta =="1"){
retornaTipoContaRaiz();
}
}});
In HTML you have
divInstituicaoEstrangeira
in Javascript you havedocument.getElementById("divInstituicao")
. They’re different names... meaning the content is withdisplay: none;
also.– Sergio
Thanks Sergio, I’ll change here
– Priscila.pcs