When the focus is on the checkbox and the user presses enter, I need the value to be active or inactive depending on which its state, and also focus a button, the focus works but the value is not being updated, this is what I have so far:
SelectBooleanCheckBox:
<p:selectBooleanCheckbox id="sbcActivoProp" widgetVar="sbcActivoPropWV" onchange="document.getElementById('frmGuardarActualizarPropiedad:btnGuardarPropiedad').focus(); return false;"
binding="#{programaAccesoMB.sbcActivoProp}"
label="#{etiquetasMsg.general_activo}" disabled="false">
</p:selectBooleanCheckbox>
Javascript:
<script type="text/javascript">
var focusSbcActivoProp = document.getElementById('frmGuardarActualizarPropiedad:sbcActivoProp_input');
if (focusSbcActivoProp != null) {
focusSbcActivoProp.onkeydown = function(event) {
if (event.keyCode == 13) {
var ischecked = sbcActivoPropWV.input.is(':checked');
if(ischecked){
console.log('is checked');
document.getElementById('frmGuardarActualizarPropiedad:sbcActivoProp').value=false;
}else{
console.log('is not checked');
document.getElementById('frmGuardarActualizarPropiedad:sbcActivoProp').value=true;
}
document.getElementById('frmGuardarActualizarPropiedad:btnGuardarPropiedad').focus();
}
return false;
}
};
</script>