How to uncheck a checkbox when another is selected?

Asked

Viewed 160 times

1

<t:selectOneRadio layout="pageDirection"
                        forceId="true" forceIdIndex="false" id="selectCodigoProcesso"
                        rendered="#{!bkbCadastroPessoaJuridica.orgaoEntidade}"
                        styleClass="envolveRadio"
                        valueChangeListener="#{actCadastroPessoaJuridica.selecaoCnpjNomeLst}"
                        onclick="setColorRadioGroupJSF();mudaInput('selectCodigoProcesso'); SetSel(selectCodigoProcesso);"
                        binding="#{actCadastroPessoaJuridica.selectRadioCnpj}">
                        <!-- Olá mundo -->
                        <f:selectItem itemValue="cnpj" id="codigoProcesso" itemLabel="" />

                    </t:selectOneRadio>


<t:selectOneRadio layout="pageDirection"
                        forceId="true" forceIdIndex="false" id="selectCodigoProcesso"
                        rendered="#{!bkbCadastroPessoaJuridica.orgaoEntidade}"
                        styleClass="envolveRadio"
                        valueChangeListener="#{actCadastroPessoaJuridica.selecaoCnpjNomeLst}"
                        onclick="setColorRadioGroupJSF();mudaInput('selectCodigoProcesso'); SetSel(selectCodigoProcesso);"
                        binding="#{actCadastroPessoaJuridica.selectRadioCnpj}">
                        <!-- Olá mundo -->
                        <f:selectItem itemValue="cnpj" id="codigoProcesso" itemLabel="" />

                    </t:selectOneRadio>
  • What code do you have so far? puts the change code();

  • Function mudaInput (nameRadio) {&#xA; //alert("body on load mudaInput document.getElementById(nameRadio)"+document.getElementById(nameRadio));&#xA; if(document.getElementById(nameRadio) != null){&#xA; // alert("entrou mudaInput");&#xA; var objects = document.getElementsByTagName("INPUT"); for (var i=0; i<Objects.length; i++) { thisElement = Objects[i];

  • if (thisElement.getattribute("type") == "radio") { // window.Alert (thisElement.name); //window.Alert (nameRadio); //Alert("thisElement.name"+thisElement.name); // Alert("nameRadio"+nameRadio); if (thisElement.checked && thisElement.name == nameRadio) { radioSelected = thisElement.value; } } }

  • var Objects = Document.getelementsbytagname("INPUT"); for (var i=0; i<Objects.length; i++) { var thisElement = Objects[i]; if (thisElement.getattribute("type") == "text") { if (radioSelected == "cnpj") { if (thisElement.id == "form:numero") { thisElement.disabled = false; } Else { //thisElement.disabled = true; }

  • } Else if (radioSelected == "name") { if (thisElement.id == "form:textText") { thisElement.disabled = false; } Else { //thisElement.disabled = true; } } } } } Else {

  • var Objects = Document.getelementsbytagname("INPUT"); for (var i=0; i<Objects.length; i++) { thisElement = Objects[i]; if (thisElement.getattribute("type") == "radio") { thisElement.checked = false; } } } } }

  • puts in question and not in comments.

  • Wouldn’t it be easier for you to change your HTML and instead of using Checkbox to use Radio buttons?? Radio buttons already have this function (deselect one when marking the other) natively.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.