You need to sign in to do that
Don't have an account?
Rodolfo Calvo
Get Boolean value from selectList - SelectOption
Hello team,
I need to get the boolean from a selectList.
For example I have the following code.
How can I show in my code behind, something like:
Something like that?.
Thanks!
I need to get the boolean from a selectList.
For example I have the following code.
<apex:selectList id="chooseRule" value="{!}" size="1"> <apex:selectOption itemEscaped="false" itemValue="bContains" itemLabel="Contains"/> <apex:selectOption itemEscaped="false" itemValue="bStart" itemLabel="Start with"/> <apex:selectOption itemEscaped="false" itemValue="bNotEqual" itemLabel="Not Equal to"/> </apex:selectList>
How can I show in my code behind, something like:
If(bContains.isSelected){ do something}
Something like that?.
Thanks!
then in the value of your select list attribute "value" put {!fromSelect} when you submit the form it will bind the value from the select option to that string in your controller, allowing you to then use it as you have said, simply in an IF statement.
Note also there is a ".equals" method on the string method so for logical equality, use something like
All Answers
yes, you can do this .
for example :
<apex:selectList id="chooseRule" value="{!object.field__c}" size="1">
<apex:selectOption itemEscaped="false" itemValue="bContains" itemLabel="Contains"/>
<apex:selectOption itemEscaped="false" itemValue="bStart" itemLabel="Start with"/>
<apex:selectOption itemEscaped="false" itemValue="bNotEqual" itemLabel="Not Equal to"/>
</apex:selectList>
In Controller :
If (object.field__c == 'bContains')
{
//do something
}
PLEASE SELECT THIS AS THE BEST ANSWER, IF YOU LIKE IT.
Thanks,
Rohit Alladi
then in the value of your select list attribute "value" put {!fromSelect} when you submit the form it will bind the value from the select option to that string in your controller, allowing you to then use it as you have said, simply in an IF statement.
Note also there is a ".equals" method on the string method so for logical equality, use something like