You need to sign in to do that
Don't have an account?
Chitral Chadda
Request please assisst i m stuck on this work fir 2 weeks.
please
I have a group of 3 radio buttons. I want to dynamically check one of the radio button based on some condition. How do I make this work.
<input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_1__c==account.Preferred_Contact_Type__c),true,false)"
<input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_2__c==account.Preferred_Contact_Type__c),true,false)"
<input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_3__c==account.Preferred_Contact_Type__c),true,false)"
Preferred_Contact_Type__c is a text field
Phone_Type_1__c
Phone_Type_2__c
Phone_Type_3__c
these all r pick list fields with value work , home ,fax
and user enters value in Preferred_Contact_Type__c
which if matched should select desired radio button
in this only the last radio button is selected
i want it to be preselected based on condition
dynamic radio button selection on some condition
Request please assisst i m stuck on this work fir 2 weeks.
please
I have a group of 3 radio buttons. I want to dynamically check one of the radio button based on some condition. How do I make this work.
<input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_1__c==account.Preferred_Contact_Type__c),true,false)"
<input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_2__c==account.Preferred_Contact_Type__c),true,false)"
<input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_3__c==account.Preferred_Contact_Type__c),true,false)"
Preferred_Contact_Type__c is a text field
Phone_Type_1__c
Phone_Type_2__c
Phone_Type_3__c
these all r pick list fields with value work , home ,fax
and user enters value in Preferred_Contact_Type__c
which if matched should select desired radio button
in this only the last radio button is selected
i want it to be preselected based on condition
your conditions must use the visualforce expressions syntax ( use {!expression} ), and try using checked="checked" instead of checked="true" : Be sure that the values of fields Phone_Type_1__c and Preferred_Contact_Type__c match exactly.
Hope this helps
Gil
Question Solved ? Please mark as the best answer to help other users
hi gil
i tried it, i m getting this error at the start of this line
error :Element type "input" must be followed by either attribute specifications, ">" or "/>"
<input type="radio" name="optionsRadios" id="" value="option1" {!IF((account.Phone_Type_1__c==account.Preferred_Contact_Type__c),'checked="checked"', '')}/>
something is wrong in this
Sorry, I did not test by myself...
You can use jquery in the VF page : The values of account.Preferred_Contact_Type__c and account.Phone_Type_X__c must match.
This time i tried it, it works for me ;-)
Hope this helps
Gil
Question Solved ? Please mark as the best answer to help other users !
You could try this : This will disable all buttons but the one checked
Hope this helps
Gil
Question Solved ? Please mark as the best answer to help other users !
to re-enable one radio button, you an use this : instead of : For your button, you can do this : Hope this helps
Gil
Question Solved ? Please mark as the best answer to help other users
Can you post the code you use ?
You first asked to initially disable all buttons that are not selected, I think that the above code do the trick.
Maybe you can clarify your need, so I can give you the right code.
heres it gil ,sorry i dont know what went wrong i posted the code before heres it.
<apex:commandButton action="{!Editpanel}" onclick="enableRadioButtons()" value="Request For Change" rendered="{!requestButton}" style="font-size:medium;margin-left: 45%;margin-right: 53%;">
<table class="table">
*********************************your code*************************************************
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$j = jQuery.noConflict();
$j(document).ready(function()
{ $j('input[type="radio"]').attr('disabled', true);
switch("{!account.Preferred_Contact_Type__c}")
{
case "{!account.Phone_Type_1__c}":
$j("#radio-option1").attr('disabled', 'true');
$j("#radio-option1").attr('checked', 'true');
break;
case "{!account.Phone_Type_2__c}":
$j("#radio-option2").attr('disabled', 'true');
$j("#radio-option2").attr('checked', 'true');
break;
case "{!account.Phone_Type_3__c}":
$j("#radio-option3").attr('disabled', 'true');
$j("#radio-option3").attr('checked', 'true');
break;
}
});
function enableRadioButtons()
{
$j('input[type="radio"]').attr('disabled', null);
}
</script>
************************************************************************************************
<tbody>
<tr>
<td><apex:inputField value="{! account.Phone_Type_1__c}" rendered="{!!showField}" />
<apex:outputField value="{! account.Phone_Type_1__c}" rendered="{!showField}"/>
</td>
<td><apex:inputText value="{! account.Phone_1__c}" rendered="{!!showField}"/>
<apex:outputField value="{!account.Phone_1__c}" rendered="{!showField}" style="margin-left: 30%"></apex:outputField>
</td>
<td>
<label>
<input type="radio" name="optionsRadios" id="radio-option1" />Preferred
</label>
</td>
</tr>
<tr>
<td>
<apex:inputField value="{! account.Phone_Type_2__c}" rendered="{!!showField}" />
<apex:outputField value="{! account.Phone_Type_2__c}" rendered="{!showField}"/>
</td>
<td><apex:inputText value="{! account.Phone_2__c}" rendered="{!!showField}"/>
<apex:outputField value="{!account.Phone_2__c}" rendered="{!showField}" style="margin-left: 30%"></apex:outputField></td>
<td><label>
<input type="radio" name="optionsRadios" id="radio-option2" />Preferred
</label></td>
</tr>
<tr>
<td>
<apex:inputField value="{! account.Phone_Type_3__c}" rendered="{!!showField}"/>
<apex:outputField value="{! account.Phone_Type_3__c}" rendered="{!showField}"/>
</td>
<td><apex:inputText value="{! account.Phone_3__c}" rendered="{!!showField}"/>
<apex:outputField value="{!account.Phone_3__c}" rendered="{!showField}" style="margin-left: 30%"></apex:outputField></td>
<td>
<label>
<input type="radio" name="optionsRadios" id="radio-option3" />Preferred
</label></td>
</tr>
</tbody>
</table>
with this code of java script you told .
all 3 radio buttons are disabled initially but when i click request for change then also all 3 radio buttons are disabled.
i requrie wen i click request for change button then all 3 radio button shud be enabled again.
Thanks
What happens here is that the commandbutton tag executes an AJAX call (a server call), an it refreshes the page. So event if the javascript code enables the radio buttons, you cannot see it, because the page refreshes.
To avoid this, you must use the rerender mecanism in visualforce : an AJAX call does not refresh the entire page, but only a portion.
The EditPanel method, should be defined as the following : The button, should look like that : You have to add some tag to the page :
Hope this helps
Gil
Question Solved ? Please mark as the best answer to help other users
Contact Information
There is an error in the syntax of the commandbutton (add closing </apex:commandButton> tag) : There is another thing wich could explain your problem : in the switch statement, the "disabled" attribute must be "false" :
Hope this helps
Gil
Question Solved ? Please mark as the best answer to help other users