Skip to main content
deleted 3 characters in body
Source Link
vorno
  • 106
  • 5

You can add an onchange event for the checkbox field to check the value of the checkbox, and uncheck all the other checkboxes if required:

<apex:inputField value="{!attendee.Primary_Client_Attendee__c}" style="width:300px" onchange="oneCheckbox(this);" />

<script>
function oneCheckbox(obj)
{
    if (obj.checked)
    {
        var inputs = document.getElementsByTagName("input");

        for (var i = 0; i < inputs.length; i++)
        {
            var oInput = inputs[i];
            if (oInput.type == "checkbox" && oInput.checked && oInput != obj)
            {
                inputs[i]oInput.checked = false; 
            }  
        }
    }

}
</script>

This script finds -every- checkbox field on the page and unchecks them as required, so if you have other checkboxes that shouldn't be checked you will need to add a more specific document selector.

HTH.

You can add an onchange event for the checkbox field to check the value of the checkbox, and uncheck all the other checkboxes if required:

<apex:inputField value="{!attendee.Primary_Client_Attendee__c}" style="width:300px" onchange="oneCheckbox(this);" />

<script>
function oneCheckbox(obj)
{
    if (obj.checked)
    {
        var inputs = document.getElementsByTagName("input");

        for (var i = 0; i < inputs.length; i++)
        {
            var oInput = inputs[i];
            if (oInput.type == "checkbox" && oInput.checked && oInput != obj)
            {
                inputs[i].checked = false; 
            }  
        }
    }

}
</script>

This script finds -every- checkbox field on the page and unchecks them as required, so if you have other checkboxes that shouldn't be checked you will need to add a more specific document selector.

HTH.

You can add an onchange event for the checkbox field to check the value of the checkbox, and uncheck all the other checkboxes if required:

<apex:inputField value="{!attendee.Primary_Client_Attendee__c}" style="width:300px" onchange="oneCheckbox(this);" />

<script>
function oneCheckbox(obj)
{
    if (obj.checked)
    {
        var inputs = document.getElementsByTagName("input");

        for (var i = 0; i < inputs.length; i++)
        {
            var oInput = inputs[i];
            if (oInput.type == "checkbox" && oInput.checked && oInput != obj)
            {
                oInput.checked = false; 
            }  
        }
    }

}
</script>

This script finds -every- checkbox field on the page and unchecks them as required, so if you have other checkboxes that shouldn't be checked you will need to add a more specific document selector.

HTH.

Source Link
vorno
  • 106
  • 5

You can add an onchange event for the checkbox field to check the value of the checkbox, and uncheck all the other checkboxes if required:

<apex:inputField value="{!attendee.Primary_Client_Attendee__c}" style="width:300px" onchange="oneCheckbox(this);" />

<script>
function oneCheckbox(obj)
{
    if (obj.checked)
    {
        var inputs = document.getElementsByTagName("input");

        for (var i = 0; i < inputs.length; i++)
        {
            var oInput = inputs[i];
            if (oInput.type == "checkbox" && oInput.checked && oInput != obj)
            {
                inputs[i].checked = false; 
            }  
        }
    }

}
</script>

This script finds -every- checkbox field on the page and unchecks them as required, so if you have other checkboxes that shouldn't be checked you will need to add a more specific document selector.

HTH.