I have an issue. I have 2 forms on the page and one is not visible
<h:form id="selres">
.....
<h:commandButton value="Rezerwuj" actionListener="#{reservation.getPatient}" action="#{reservation.rezerwuj()}" onclick="javascript:hide();" >
</h:commandButton>
.....
</h:form>
<h:form id="confRes" style="display: none">
.....
</h:form>
and javascript
function hide(){
var conf = document.getElementById("confRes");
var res = document.getElementById("selres");
if (conf.style.display=="none"){
conf.style.display="block";
res.style.display="none";
}
else{
conf.style.display="none";
res.style.display="block";
}
}
the problem is that commandButton makes submit and refreshes the page after javascript will show confRes form so it will be hidden again.
What should I do to:
- submit the action
- hide selres form
- show confRes form