You need to sign in to do that
Don't have an account?
Shubham Mirketa
apex:selectlist sending blank to the bound controller varibale
I have a apex:selectList on my VF page and a controller variable is bound to it. But whenever i select anything in the list, it stores a blank in the controller variable. I am facing this problem only when i run my page on Firefox or IE. It works fine in Chrome.
My selectList is as follows:
<apex:selectList id="objectList" onchange="$('#err2').hide(); oOptVal=this.value;" styleClass="select-menu" style="padding-left: 10px;" value="{!selectobject}" size="1" >
<apex:selectOption itemValue="None" itemLabel="Please select" />
<apex:selectOption itemValue="Account" itemLabel="Account" />
<apex:selectOption itemValue="Contact" itemLabel="Contact"/>
<apex:selectOption itemValue="Lead" itemLabel="Lead" />
</apex:selectList>
The bound variable is also declared correctly,
public String selectobject{get;set;}
Still, it throws a blank value whenever anything is selected.
Can anyone help in fixing this?
Thanks & Regards
Shubham Jha
My selectList is as follows:
<apex:selectList id="objectList" onchange="$('#err2').hide(); oOptVal=this.value;" styleClass="select-menu" style="padding-left: 10px;" value="{!selectobject}" size="1" >
<apex:selectOption itemValue="None" itemLabel="Please select" />
<apex:selectOption itemValue="Account" itemLabel="Account" />
<apex:selectOption itemValue="Contact" itemLabel="Contact"/>
<apex:selectOption itemValue="Lead" itemLabel="Lead" />
</apex:selectList>
The bound variable is also declared correctly,
public String selectobject{get;set;}
Still, it throws a blank value whenever anything is selected.
Can anyone help in fixing this?
Thanks & Regards
Shubham Jha
You should initialize the variable in Constructor before referencing it.
like this:
selectObject = '';
Thanks for the response. But i have initialised the variable in the constructor.