You need to sign in to do that
Don't have an account?

Checkbox field in VF page
Hi All,
I have two check boxes named A and B in my custom object. In my visualforce page
If I select A then B should be unselected and vice versa.
How to do this?
I don't want to use picklist at the backend and use select option at the front end.
I want to use only checkboxes.
Pls help me in this.
If you want to use Checkbox only and same time want functionality like radio button, then you can write some javascript to do this for you.
<apex:page>
<script>
function uncheckOther(elm) {
// first set noth checkbox as unchecked (reset)
document.getElementById('{!$Component:frm:inptCheck1}').checked=false;
document.getElementById('{!$Component:frm:inptCheck2}').checked=false;
// then set the current one as checked
elm.checked=true;
}
</script>
<apex:form id="frm">
<apex:inputCheckbox id="inptCheck1" value="{!yourObj.A__c}" onClick="uncheckOther(this)"/>
<apex:inputCheckbox id="inptCheck2" value="{!yourObj.B__c}" onClick="uncheckOther(this)"/>
</apex:form>
</apex:page>
Let me know if this helps.