I have a jsf form which has a command Button and I have some list of items. So i am going to disable the button when user Selected items count is greater than certain limit(assume it as 10) and again it should enable it back if that count is less than 10 .
My code is working till disabling the button but when the count is less than 10 it not able to enable it again .
Pls check my code below and help
<h:commandButton id="addButton" value=" ADD -- > " action="#{CW.addTraffic}" disabled="false" onclick="return countValidation();"/>
In js , i wrote the logic for comparing the count
I should show 3 counts in my page . one is max count which is 10 and selectedcount which is coming when we select items and Permit count which is ..
permitcount= 10 - selectedcount (this vaklue will becomes neagtive if we select more than 10)
if(permitcount<0)
{
document.getElementById("main:addButton").disabled='true'; // disable the button
}
else
{
document.getElementById("main:addButton").disabled='false'; // this should enable .
}
but it not enabling the button back once it is disabled . pls help me