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

pass value from radio button to controller
hi here is my VF code-------------------
<apex:pageBlock >
<apex:pageBlockTable value="{!wrpR}" var="proR" id="RadioP">
<apex:column >
<apex:facet name="header"></apex:facet>
<!-- <apex:selectRadio value="{!proR.obj.id}" label="Radio">
<apex:selectOptions value="{!Hi}"/>
</apex:selectRadio>-->
<input type="radio" name="group1" id="{!proR.isSelected}"/> <!--id="{!proR.obj.Id}"-->
</apex:column>
<apex:column >
<apex:facet name="header">
Financial Product
</apex:facet>
<apex:outputtext value="{!proR.obj.Name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
Term
</apex:facet>
<apex:inputField value="{!proR.obj.Term__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
Frequency
</apex:facet>
<apex:inputField value="{!proR.obj.Frequency__c}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons location="bottom" style="float:right;">
<apex:commandButton onclick="getSelectedContact(group1);" value="next" id="btn3" reRender="form"/>
<apex:actionFunction name="next" action="{!next}" rerender="Msgs">
<apex:param name="selected" value=""/>
</apex:actionFunction>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
<script>
function getSelectedContact(group1)
{
var theRadioButtonSet = document.getElementsByTagName('input');
for (var i = 0; i < theRadioButtonSet.length; i++) {
var node = theRadioButtonSet[i];
if (node.getAttribute('type') == 'radio') {
if(node.checked)
{
// alert(node.value);
var IsonOrNot=node.value;
callToSetSelectedFields(IsonOrNot);
}
}
}
}
</script>
And here is my controller wrapper class------------------
public class Account_Search_Controller
{
public List<SelectedRecordWrapperRadio> wrpR {get;set;}
public Account_Search_Controller()
{
wrpR=new List<SelectedRecordWrapperRadio>();
for(Pricing__c PP:p)
{
wrpR.add(new SelectedRecordWrapperRadio(PP));
}
}
public class SelectedRecordWrapperRadio
{
public Pricing__c obj{get;set;}
public boolean isSelected{get;set;}
public SelectedRecordWrapperRadio(Pricing__c s)
{
this.obj=s;
isSelected=false;
if(isSelected==true){
system.debug('its selected');
}
}
}
}
i basically want when a radio button is selected its value is passed to a controller...... please help.... I am not able to do it..... i am new to wrapper and vf..............
<apex:pageBlock >
<apex:pageBlockTable value="{!wrpR}" var="proR" id="RadioP">
<apex:column >
<apex:facet name="header"></apex:facet>
<!-- <apex:selectRadio value="{!proR.obj.id}" label="Radio">
<apex:selectOptions value="{!Hi}"/>
</apex:selectRadio>-->
<input type="radio" name="group1" id="{!proR.isSelected}"/> <!--id="{!proR.obj.Id}"-->
</apex:column>
<apex:column >
<apex:facet name="header">
Financial Product
</apex:facet>
<apex:outputtext value="{!proR.obj.Name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
Term
</apex:facet>
<apex:inputField value="{!proR.obj.Term__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
Frequency
</apex:facet>
<apex:inputField value="{!proR.obj.Frequency__c}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons location="bottom" style="float:right;">
<apex:commandButton onclick="getSelectedContact(group1);" value="next" id="btn3" reRender="form"/>
<apex:actionFunction name="next" action="{!next}" rerender="Msgs">
<apex:param name="selected" value=""/>
</apex:actionFunction>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
<script>
function getSelectedContact(group1)
{
var theRadioButtonSet = document.getElementsByTagName('input');
for (var i = 0; i < theRadioButtonSet.length; i++) {
var node = theRadioButtonSet[i];
if (node.getAttribute('type') == 'radio') {
if(node.checked)
{
// alert(node.value);
var IsonOrNot=node.value;
callToSetSelectedFields(IsonOrNot);
}
}
}
}
</script>
And here is my controller wrapper class------------------
public class Account_Search_Controller
{
public List<SelectedRecordWrapperRadio> wrpR {get;set;}
public Account_Search_Controller()
{
wrpR=new List<SelectedRecordWrapperRadio>();
for(Pricing__c PP:p)
{
wrpR.add(new SelectedRecordWrapperRadio(PP));
}
}
public class SelectedRecordWrapperRadio
{
public Pricing__c obj{get;set;}
public boolean isSelected{get;set;}
public SelectedRecordWrapperRadio(Pricing__c s)
{
this.obj=s;
isSelected=false;
if(isSelected==true){
system.debug('its selected');
}
}
}
}
i basically want when a radio button is selected its value is passed to a controller...... please help.... I am not able to do it..... i am new to wrapper and vf..............
This is documented at:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_selectRadio.htm
Are you experiencing a particular problem? At the moment it looks like your selectradio is commented out in the page, which means no value will be saved to the controller.