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
Hari nadh babu EluruHari nadh babu Eluru 

picklist image load

Hi all,
One picklist is there, it consists values of Pulsar, FZ, Glamour above three values had a three bike images.At in picklist we select pulsar then pulsar image can be show remaining images can be hide, if FZ is select from picklist then FZ iamge can be show and remaining images can be hide, if Glamour is selected from picklist then Glamour image can be show remaining images can be hide

The above is the code that i tried
VF Code
<apex:page controller="Picklist_Show_Hide_Img_Con">
<apex:form >
<apex:selectList id="Picklist_Show_Hide_Img_Con" value="{!w}" size="1">
<apex:actionSupport action="{!showhideimg}" event="onchange"/>
            <apex:selectOption itemValue="Pulsar" itemLabel="Pulsar"/>
            <apex:selectOption itemValue="FZ" itemLabel="FZ"/>
            <apex:selectOption itemValue="Glamour" itemLabel="Glamour"/>
</apex:selectList> <br />
<apex:image value="{!$Resource.Pulsar}" rendered="{!x}" width="200" height="200"/>
<apex:image value="{!$Resource.FZ}" rendered="{!y}" width="200" height="200"/>
<apex:image value="{!$Resource.Glamour}" rendered="{!z}" width="200" height="200"/>
</apex:form>
</apex:page>
Apex Code
public class Picklist_Show_Hide_Img_Con {

    public Boolean z { get; set; }

    public Boolean y { get; set; }

    public Boolean x { get; set; }
    
    public Picklist_Show_Hide_Img_Con() {
        x = true;
        y = true;
        z = true;
    }
    
    public PageReference showhideimg() {
        if(w==x){
            x = true;
            y = false;
            z = false;
        }
        
        if(w==y){
            x = false;
            y = true;
            z = false;
        }
        
        if(w==z){
            x = false;
            y = false;
            z = true;
        }
        return null;
    }


    public String w { get; set; }
}
Please rectify my problem. Thank you very much !

 
Best Answer chosen by Hari nadh babu Eluru
Aneesh AllumallaAneesh Allumalla

Hi Hari,

You just need make this change in the Apex class.
In the method  public PageReference showhideimg(),
instead of w==x , w==y, w==z, use as below.
Also in the contsructor ,x , y, z values should be false.
So  your apex class should look like this.

public class Picklist_Show_Hide_Img_Con {

    public Boolean z { get; set; }

    public Boolean y { get; set; }

    public Boolean x { get; set; }
    
    public Picklist_Show_Hide_Img_Con() {
        x = false;
        y = false;
        z = false;
    }
    
    public PageReference showhideimg() {
        if(w == 'Pulsar'){
            x = true;
            y = false;
            z = false;
        }
        
        else if(w== 'FZ'){
            x = false;
            y = true;
            z = false;
        }
        
        else if(w== 'Glamour'){
            x = false;
            y = false;
            z = true;
        }
       
        return null;
    }


    public String w { get; set; }
}

Please let me know if you need help.

Please mark this as best answer if you find it helpful.

 

All Answers

Aneesh AllumallaAneesh Allumalla

Hi Hari,

You just need make this change in the Apex class.
In the method  public PageReference showhideimg(),
instead of w==x , w==y, w==z, use as below.
Also in the contsructor ,x , y, z values should be false.
So  your apex class should look like this.

public class Picklist_Show_Hide_Img_Con {

    public Boolean z { get; set; }

    public Boolean y { get; set; }

    public Boolean x { get; set; }
    
    public Picklist_Show_Hide_Img_Con() {
        x = false;
        y = false;
        z = false;
    }
    
    public PageReference showhideimg() {
        if(w == 'Pulsar'){
            x = true;
            y = false;
            z = false;
        }
        
        else if(w== 'FZ'){
            x = false;
            y = true;
            z = false;
        }
        
        else if(w== 'Glamour'){
            x = false;
            y = false;
            z = true;
        }
       
        return null;
    }


    public String w { get; set; }
}

Please let me know if you need help.

Please mark this as best answer if you find it helpful.

 

This was selected as the best answer
Hari nadh babu EluruHari nadh babu Eluru
@Aneesh Allumalla Thank you ! very much