You need to sign in to do that
Don't have an account?
uptime_andrew
Conditional Checked setting for Input Field
I have a checkbox field, which in my Visualforce page am displaying as 2 radio fields (by request from the business).
When trying to set which option is checked, I am always getting the second checked, even if I have checked="false" or checked="". I cannot seem to set checked=false.
<apex:pageBlockSectionItem labelStyleClass="checkboxLabel" dataStyleClass="myCheckbox" id="primary1YesBox"> <apex:outputLabel value="Yes" for="primary1True"/> <input type="radio" name="primary1" value="True" id='primary1True' onclick="document.getElementById('{!$Component.customField__c}').checked=true" checked="{!IF(opportunity.customField__c=true,'checked','')}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem labelStyleClass="checkboxLabel" dataStyleClass="myCheckbox"> <apex:outputLabel value="No" for="primary1False"/> <input type="radio" name="primary1" value="False" id='primary1False' onclick="document.getElementById('{!$Component.customField__c}').checked=false" checked="{!IF(opportunity.customField__c=false,'checked','')}" /> </apex:pageBlockSectionItem>
Right now, the 2nd options is always checked. How can I get this running so that the first option is checked when customField__c is true?
Hey
Rather use a selectRadio component as shown here: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_selectRadio.htm
You can then set the "value" atttribute of the selectRadio component server-side i.e. in your Apex code. For example:
Here I've set the default or "checked" option to "US' and this is what will be selected on page load.
Cheers,
Wes
All Answers
Hey
Rather use a selectRadio component as shown here: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_selectRadio.htm
You can then set the "value" atttribute of the selectRadio component server-side i.e. in your Apex code. For example:
Here I've set the default or "checked" option to "US' and this is what will be selected on page load.
Cheers,
Wes
Thanks weznolte!