You need to sign in to do that
Don't have an account?
Venkata Sravan Kumar Bandari
Hi, I hav an issue that I want to display an image when changing the values of picklist
Here is the code....Image is not displaying
<apex:page controller="Task_Picklist_onChange">
<apex:form id="show">
<apex:pageblock >
<apex:pageblockSection >
<apex:outputPanel >
<apex:selectList value="{!colors}" size="1">
<apex:actionSupport event="onChange" action="{!display}" reRender="show" />
<apex:selectOptions value="{!images}"/>
</apex:selectList>
</apex:outputPanel>
</apex:pageblockSection>
</apex:pageblock>
<apex:outputPanel >
<apex:image rendered="{!colors = 'Green'}" value="{!$Resource.Green}" width="200" height="200"/>
<apex:image rendered="{!colors = 'Red'}" value="{!$Resource.Red}" width="200" height="200"/>
<apex:image rendered="{!colors ='Yellow'}" value="{!$Resource.Yellow}" width="200" height="200"/>
<apex:image rendered="{!colors ='Orange'}" value="{!$Resource.Orange}" width="200" height="200"/>
</apex:outputPanel>
</apex:form>
</apex:page>
public with sharing class Task_Picklist_onChange {
String Color;
public PageReference display() {
return null;
}
public String images { set; }
public list<selectoption> getimages() {
list<selectoption> image = new list<selectoption>();
image.add(new selectoption('None','No'));
image.add(new selectoption('Green','Green'));
image.add(new selectoption('Red','Red'));
image.add(new selectoption('yellow','Yellow'));
image.add(new selectoption('Orange','Orange'));
return image;
}
public String colors { get; }
Public String setcolors(String colors) {
System.debug(colors);
color = colors;
return color;
}
}
<apex:page controller="Task_Picklist_onChange">
<apex:form id="show">
<apex:pageblock >
<apex:pageblockSection >
<apex:outputPanel >
<apex:selectList value="{!colors}" size="1">
<apex:actionSupport event="onChange" action="{!display}" reRender="show" />
<apex:selectOptions value="{!images}"/>
</apex:selectList>
</apex:outputPanel>
</apex:pageblockSection>
</apex:pageblock>
<apex:outputPanel >
<apex:image rendered="{!colors = 'Green'}" value="{!$Resource.Green}" width="200" height="200"/>
<apex:image rendered="{!colors = 'Red'}" value="{!$Resource.Red}" width="200" height="200"/>
<apex:image rendered="{!colors ='Yellow'}" value="{!$Resource.Yellow}" width="200" height="200"/>
<apex:image rendered="{!colors ='Orange'}" value="{!$Resource.Orange}" width="200" height="200"/>
</apex:outputPanel>
</apex:form>
</apex:page>
public with sharing class Task_Picklist_onChange {
String Color;
public PageReference display() {
return null;
}
public String images { set; }
public list<selectoption> getimages() {
list<selectoption> image = new list<selectoption>();
image.add(new selectoption('None','No'));
image.add(new selectoption('Green','Green'));
image.add(new selectoption('Red','Red'));
image.add(new selectoption('yellow','Yellow'));
image.add(new selectoption('Orange','Orange'));
return image;
}
public String colors { get; }
Public String setcolors(String colors) {
System.debug(colors);
color = colors;
return color;
}
}
VF:
<apex:page controller="Task_Picklist_onChange">
<apex:form >
<apex:pageblock >
<apex:pageblockSection >
<apex:outputPanel >
<apex:selectList value="{!colors}" size="1" title="Color">
<apex:selectOptions value="{!images}"/>
<apex:actionSupport event="onchange" reRender="show"/>
</apex:selectList>
</apex:outputPanel>
</apex:pageblockSection>
</apex:pageblock>
<apex:outputPanel id="show">
<apex:image rendered="{!colors = 'Green'}" value="{!$Resource.Green}" width="200" height="200"/>
<apex:image rendered="{!colors ='Red'}" value="{!$Resource.Red}" width="200" height="200"/>
<apex:image rendered="{!colors ='Yellow'}" value="{!$Resource.Yellow}" width="200" height="200"/>
<apex:image rendered="{!colors ='Orange'}" value="{!$Resource.Orange}" width="200" height="200"/>
</apex:outputPanel>
</apex:form>
</apex:page>
Controller:
public with sharing class Task_Picklist_onChange {
String colors;
public PageReference display() {
return null;
}
public String images { set; }
public list<selectoption> getimages() {
list<selectoption> image = new list<selectoption>();
image.add(new selectoption('None','No'));
image.add(new selectoption('Green','Green'));
image.add(new selectoption('Red','Red'));
image.add(new selectoption('yellow','Yellow'));
image.add(new selectoption('Orange','Orange'));
return image;
}
public String getcolors() {
return colors;
}
Public void setcolors(String colors) {
this.colors = colors;
}
}
All Answers
Check the below link and change accordingly.
http://www.infallibletechie.com/2012/10/dependent-picklist-using-apex-in.html
I made some changes in your code.
Try the below one.
VF:
<apex:page controller="Task_Picklist_onChange">
<apex:form >
<apex:pageblock >
<apex:pageblockSection >
<apex:outputPanel >
<apex:selectList value="{!colors}" size="1" title="Color">
<apex:selectOptions value="{!images}"/>
<apex:actionSupport event="onchange" reRender="show"/>
</apex:selectList>
</apex:outputPanel>
</apex:pageblockSection>
</apex:pageblock>
<apex:outputPanel id="show">
<apex:image rendered="{!colors = 'Green'}" value="{!$Resource.Green}" width="200" height="200"/>
<apex:image rendered="{!colors ='Red'}" value="{!$Resource.Red}" width="200" height="200"/>
<apex:image rendered="{!colors ='Yellow'}" value="{!$Resource.Yellow}" width="200" height="200"/>
<apex:image rendered="{!colors ='Orange'}" value="{!$Resource.Orange}" width="200" height="200"/>
</apex:outputPanel>
</apex:form>
</apex:page>
Controller:
public with sharing class Task_Picklist_onChange {
String colors;
public PageReference display() {
return null;
}
public String images { set; }
public list<selectoption> getimages() {
list<selectoption> image = new list<selectoption>();
image.add(new selectoption('None','No'));
image.add(new selectoption('Green','Green'));
image.add(new selectoption('Red','Red'));
image.add(new selectoption('yellow','Yellow'));
image.add(new selectoption('Orange','Orange'));
return image;
}
public String getcolors() {
return colors;
}
Public void setcolors(String colors) {
this.colors = colors;
}
}
Hi Sonam, it is also not working.
Did you make any changing in the cde by any chance: