Conditional Checkbox

Asked

Viewed 53 times

0

I need to perform a validation when selecting some options in the following checkbox:

inserir a descrição da imagem aqui

The rule is this::

If IMPEDITIVE is selected with "S", EXECUTED must be "N". However, both may be N but can never be both S. That is, when selecting one, the other must be downgraded, but the page (which is an editing page) will always be loaded with one of the selected options.

What I’m trying to do so far is this:

  comparaImpeditivoExecutado1(ocorrenciaSolicitacaoVO) {
if(ocorrenciaSolicitacaoVO.statusImpeditivo){
  ocorrenciaSolicitacaoVO.statusExecutado = false;
}
else {
  ocorrenciaSolicitacaoVO.statusExecutado = true;
}

}

But apparently it’s not solving.

  • 1

    You need to pass by parameter who is currently changing, so you check the status of the other, for example: if(this) other = false;

2 answers

0


You can use the tag input with the type="radio" and name="radio".

<body>
    <input class="checkClass" type="radio" name="radio" id="checkbox1">
    <label for="checkbox1">checkbox 1</label>
    <input class="checkClass" type="radio" name="radio" id="checkbox2">
    <label for="checkbox2">checkbox 2</label>
</body>

0

I transformed the values into Boolean and Component manipulate them in the following way:

checkboxExecutado(ocorrenciaSolicitacaoVO) {
ocorrenciaSolicitacaoVO.statusExecutado = !ocorrenciaSolicitacaoVO.statusExecutado;
ocorrenciaSolicitacaoVO.statusImpeditivo = false;

}

checkboxImpeditive(occurrenceSolicitacaoVO) { occurrenceYou.status occurrenceVO.statusExecuted = false; }

Answered me.

Browser other questions tagged

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