You need to sign in to do that
Don't have an account?
khushi ahuja
Issue : Two radio buttons redirecting to same vf page
Hi,
I want to develop a page which has two radio button as options : radio1 and radio2 . on click of radio1 a form of account should be avaialble and on click of radio2 a form of contact should be available.
I have my code but on click of both radio button it is redirecting to contact page only. can u help me to solve my issue
<apex:page controller="AccController">
<apex:form >
<apex:pageBlock id="pgblk">
<apex:selectRadio id="radioid" layout="pageDirection">
<apex:selectOption itemLabel="radio1" itemValue="1"></apex:selectOption>
<apex:actionSupport event="onclick" action="{!AccForm}">
</apex:actionSupport>
<apex:selectOption itemLabel="radio2" itemValue="2"></apex:selectOption>
<apex:actionSupport event="onclick" action="{!ContForm}">
</apex:actionSupport>
</apex:selectRadio>
</apex:pageBlock>
</apex:form>
</apex:page>
Here is my controller
public class AccController
{
public PageReference AccForm()
{
PageReference Page = new PageReference('/apex/CreateAcc');
Page.setRedirect(true);
return Page;
}
public PageReference ContForm()
{
PageReference Page = new PageReference('/apex/CreateContact');
Page.setRedirect(true);
return Page;
}
}
I want to develop a page which has two radio button as options : radio1 and radio2 . on click of radio1 a form of account should be avaialble and on click of radio2 a form of contact should be available.
I have my code but on click of both radio button it is redirecting to contact page only. can u help me to solve my issue
<apex:page controller="AccController">
<apex:form >
<apex:pageBlock id="pgblk">
<apex:selectRadio id="radioid" layout="pageDirection">
<apex:selectOption itemLabel="radio1" itemValue="1"></apex:selectOption>
<apex:actionSupport event="onclick" action="{!AccForm}">
</apex:actionSupport>
<apex:selectOption itemLabel="radio2" itemValue="2"></apex:selectOption>
<apex:actionSupport event="onclick" action="{!ContForm}">
</apex:actionSupport>
</apex:selectRadio>
</apex:pageBlock>
</apex:form>
</apex:page>
Here is my controller
public class AccController
{
public PageReference AccForm()
{
PageReference Page = new PageReference('/apex/CreateAcc');
Page.setRedirect(true);
return Page;
}
public PageReference ContForm()
{
PageReference Page = new PageReference('/apex/CreateContact');
Page.setRedirect(true);
return Page;
}
}
Find the updated code:
Vf Page: AccController: Make sure both the vf page exists i.e, CreateAcc and CreateContact.
You don't need to call two different function, one will do.
Hope this helps.
All Answers
Find the updated code:
Vf Page: AccController: Make sure both the vf page exists i.e, CreateAcc and CreateContact.
You don't need to call two different function, one will do.
Hope this helps.
Change your code to below.
If this helps you, please mark it as solved so that it will be availabe for others as a solution.
Best Regards,
Sandhya