You need to sign in to do that
Don't have an account?
PC
Not able to uncheck a checkbox ,Once it is checked
Hi,
I have a apex checkbox field in the vf page called "ONLY VEG". When I first click on the check box it selects only veg item from menu object and shows in the vf page. But if i want to uncheck it again so thai it will again show all the veg and non veg items,,,,,But I am not able to uncheck it again.
Checkbox in vf page:
<apex:inputCheckbox value="{!myCheckbox}"> <apex:actionSupport event="onchange" action="{!onlyveg}" /> </apex:inputCheckbox>
Controller:
public boolean myCheckbox {get; set;}
public PageReference onlyveg(){
if(myCheckbox=TRUE){
system.debug('%%%%%%%%%%%%%%%'+myCheckbox);
menu = [SELECT Category__c,CreatedById,Total_Price__c,Chef_recommended__c, CreatedDate, IsDeleted, Description__c, Image__c, ImageURL__c, LastActivityDate, LastModifiedById, LastModifiedDate, Name, Dish_Name__c, OwnerId,Price__c, Id, Remarks__c,Kids_Menu__c, Special_Dish__c,Spicy__c, Status__c, SubCategory__c, SystemModstamp, veg_non_veg__c,Information__c,Carbohydrate__c,Fats__c,Iron__c,Protein__c,Vitamin__c, (SELECT Menu__c,Price__c,Topping__c,Name FROM Toppings__r) FROM Menu__c where veg_non_veg__c='Veg'];
}else{
system.debug('%%%%%%%%%%%%%%%'+myCheckbox);
menu = [SELECT Category__c,CreatedById,Total_Price__c,Chef_recommended__c, CreatedDate, IsDeleted, Description__c, Image__c, ImageURL__c, LastActivityDate, LastModifiedById, LastModifiedDate, Name, Dish_Name__c, OwnerId,Price__c, Id, Remarks__c,Kids_Menu__c, Special_Dish__c,Spicy__c, Status__c, SubCategory__c, SystemModstamp, veg_non_veg__c,Information__c,Carbohydrate__c,Fats__c,Iron__c,Protein__c,Vitamin__c, (SELECT Menu__c,Price__c,Topping__c,Name FROM Toppings__r) FROM Menu__c where veg_non_veg__c='Non-veg'];
}
return null;
}
I have a apex checkbox field in the vf page called "ONLY VEG". When I first click on the check box it selects only veg item from menu object and shows in the vf page. But if i want to uncheck it again so thai it will again show all the veg and non veg items,,,,,But I am not able to uncheck it again.
Checkbox in vf page:
<apex:inputCheckbox value="{!myCheckbox}"> <apex:actionSupport event="onchange" action="{!onlyveg}" /> </apex:inputCheckbox>
Controller:
public boolean myCheckbox {get; set;}
public PageReference onlyveg(){
if(myCheckbox=TRUE){
system.debug('%%%%%%%%%%%%%%%'+myCheckbox);
menu = [SELECT Category__c,CreatedById,Total_Price__c,Chef_recommended__c, CreatedDate, IsDeleted, Description__c, Image__c, ImageURL__c, LastActivityDate, LastModifiedById, LastModifiedDate, Name, Dish_Name__c, OwnerId,Price__c, Id, Remarks__c,Kids_Menu__c, Special_Dish__c,Spicy__c, Status__c, SubCategory__c, SystemModstamp, veg_non_veg__c,Information__c,Carbohydrate__c,Fats__c,Iron__c,Protein__c,Vitamin__c, (SELECT Menu__c,Price__c,Topping__c,Name FROM Toppings__r) FROM Menu__c where veg_non_veg__c='Veg'];
}else{
system.debug('%%%%%%%%%%%%%%%'+myCheckbox);
menu = [SELECT Category__c,CreatedById,Total_Price__c,Chef_recommended__c, CreatedDate, IsDeleted, Description__c, Image__c, ImageURL__c, LastActivityDate, LastModifiedById, LastModifiedDate, Name, Dish_Name__c, OwnerId,Price__c, Id, Remarks__c,Kids_Menu__c, Special_Dish__c,Spicy__c, Status__c, SubCategory__c, SystemModstamp, veg_non_veg__c,Information__c,Carbohydrate__c,Fats__c,Iron__c,Protein__c,Vitamin__c, (SELECT Menu__c,Price__c,Topping__c,Name FROM Toppings__r) FROM Menu__c where veg_non_veg__c='Non-veg'];
}
return null;
}
All Answers