function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bcgbcg 

How to divide two fileds value in a picklist

Hello,

 

I have two screens one is for add room and other is for add floor. in add floor screen i have two input Fields i.e. Number of Floors and Series Start from. if i enter number of Floor= 5 and Series Start from= A then in other screen i.e. Add room Screen a picklist is created i.e. Floor in that options are like A1,A2,A3,A4,A5. these value are based on that two input fields. and the picklist is updated when a new records user create.

 

Please help me out how to do this if anyone having idea regarding this.

 

 

Thanks In Advance.

ministe2003ministe2003

You'll have to use an Apex controller/extension for this.  Create a SelectOptions list then fill it with the values taken from your drop downs.

bcgbcg

Thanks for Reply,

 

Will You please tell me how to do this? any example? or any code if you have then pls post that.

 

Thanks

ministe2003ministe2003

You need a method which creates and returns a list of select options based on the two values in the previous picklists, like so:

    public List<SelectOption> getRoomNo(){
        List<SelectOption> options = new List<SelectOption>();
        
        for(integer i = 1; i <=NumFloors; i++){
            options.add(new SelectOption(SeriesStart+''+i, SeriesStart+''+i));
        }
        return options;
    }

We create the list then populate it.  In my example I have a variable called SeriesStart which stores the "Series Start from" value and NumFloors which is the number of floors, both chosen in the previous two picklists.  I'm then iterating over NumFloors to make a list of select options. the +''+ in between SeriesStart and i is just a hacky way of making a string out of the two values.  If you have problems with that then use String.valueOf (see docs)

 

In your visualforce youd reference this list like so:

 

 

<apex:selectList value="{!myObject.fieldIWantToStoreSelectionTo__c}" size="1">
    <apex:selectoptions value="{!RoomNo}"/>
</apex:selectList>

 

 

And if none of this is making the slightest bit of sense to you then you might want to start going through the apex docs and tutorials first!

Good luck :)

 

bcgbcg

Thanks for your reply.

 

But the problem is not solved yet.Actually all i want is that i have two fields one for Series Start From ,another for No. of floors, and i have a third field which i want to be populated automatically according to the values entered in previous fields in the form of picklist.it should be something like this:

 

Series Statr From: A

No. of floors: 5

then automaticalyy filled values should be:

 

Floors:A1

A2

A3

A4

A5

in picklist and it should be dynamic.

 

Thanks in advance.

 

 

bcgbcg

Thanks for your reply.

 

But the problem is not solved yet.Actually all i want is that i have two fields one for Series Start From ,another for No. of floors, and i have a third field which i want to be populated automatically according to the values entered in previous fields in the form of picklist.it should be something like this:

 

Series Statr From: A

No. of floors: 5

then automaticalyy filled values should be:

 

Floors:A1

A2

A3

A4

A5

in picklist and it should be dynamic.

 

Thanks in advance.

 

 

ministe2003ministe2003

You would achieve that with this method.  The getRoomNo method would run on every ajax refresh so your picklist values would be updated.