You need to sign in to do that
Don't have an account?
Mayank Rana
Passing selected picklist value to apex controller using apex:actionSupport
Hi All,
I want the selected picklist value along with there domain(using <apex:param>) displayed in the below <apex:pageBlockSection> Title. I have two picklist ,As I select the value from another picklist the previous count value and domain both must be updated. But In my case count value for the first picklist value displayed null, but the last picklist slected value in displayed fine. I didnt understand its behavior. I am sending VisualForce Page and Controller.. Please give the solution
soon please..
Thanks in advance.
VisualForce Page:
<apex:page controller="Custom_Picklist" tabStyle="Contact">
<apex:form >
<apex:pageBlock >
<h1>Salesforce</h1>
<apex:selectList size="1" value="{!count}">
<apex:selectOptions value="{!numberOfQuestions }"/>
<apex:actionSupport event="onchange" action="{!showQuestions}" reRender="abcd">
<apex:param name="Domain" value="Salesforce" assignTo="{!Domain}" />
</apex:actionSupport>
</apex:selectList>
<h1>PHP</h1>
<apex:selectList size="1" value="{!count}">
<apex:selectOptions value="{!numberOfQuestions }"/>
<apex:actionSupport event="onchange" action="{!showQuestions}" reRender="abcd">
<apex:param name="Domain" value="PHP" assignTo="{!Domain}" />
</apex:actionSupport>
</apex:selectList>
<apex:pageBlockSection title="{!message}" id="abcd">
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class Custom_Picklist
{
public String count { get;set;}
public String Domain { get; set; }
public String message {get;set;}
public List<SelectOption> numberOfQuestions {get;set;}
public String selected {get;set;}
public Custom_Picklist()
{
message='';
this.getnumberOfQuestions();
}
public List<SelectOption> getnumberOfQuestions()
{
numberOfQuestions = new List<SelectOption>();
numberOfQuestions.add(new SelectOption('','--None--'));
numberOfQuestions.add(new SelectOption('5','5'));
numberOfQuestions.add(new SelectOption('10','10'));
numberOfQuestions.add(new SelectOption('20','20'));
numberOfQuestions.add(new SelectOption('30','30'));
return numberOfQuestions;
}
public void showQuestions()
{
message=Domain+'_'+count;
}
}
I want the selected picklist value along with there domain(using <apex:param>) displayed in the below <apex:pageBlockSection> Title. I have two picklist ,As I select the value from another picklist the previous count value and domain both must be updated. But In my case count value for the first picklist value displayed null, but the last picklist slected value in displayed fine. I didnt understand its behavior. I am sending VisualForce Page and Controller.. Please give the solution
soon please..
Thanks in advance.
VisualForce Page:
<apex:page controller="Custom_Picklist" tabStyle="Contact">
<apex:form >
<apex:pageBlock >
<h1>Salesforce</h1>
<apex:selectList size="1" value="{!count}">
<apex:selectOptions value="{!numberOfQuestions }"/>
<apex:actionSupport event="onchange" action="{!showQuestions}" reRender="abcd">
<apex:param name="Domain" value="Salesforce" assignTo="{!Domain}" />
</apex:actionSupport>
</apex:selectList>
<h1>PHP</h1>
<apex:selectList size="1" value="{!count}">
<apex:selectOptions value="{!numberOfQuestions }"/>
<apex:actionSupport event="onchange" action="{!showQuestions}" reRender="abcd">
<apex:param name="Domain" value="PHP" assignTo="{!Domain}" />
</apex:actionSupport>
</apex:selectList>
<apex:pageBlockSection title="{!message}" id="abcd">
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class Custom_Picklist
{
public String count { get;set;}
public String Domain { get; set; }
public String message {get;set;}
public List<SelectOption> numberOfQuestions {get;set;}
public String selected {get;set;}
public Custom_Picklist()
{
message='';
this.getnumberOfQuestions();
}
public List<SelectOption> getnumberOfQuestions()
{
numberOfQuestions = new List<SelectOption>();
numberOfQuestions.add(new SelectOption('','--None--'));
numberOfQuestions.add(new SelectOption('5','5'));
numberOfQuestions.add(new SelectOption('10','10'));
numberOfQuestions.add(new SelectOption('20','20'));
numberOfQuestions.add(new SelectOption('30','30'));
return numberOfQuestions;
}
public void showQuestions()
{
message=Domain+'_'+count;
}
}
All Answers
You were using the same variable name in both list which change the count variable value.
Instead of using single variable you should use one more variable.
I am adding corrected VF page and Apex class.
If this suggestion will help you, then mark this as a best answer!!!
otherwise tell us your doubt.