cancel
Showing results for 
Search instead for 
Did you mean: 

how to assign images as per the drop down list ?

Former Member
0 Kudos

Hi all,

what i want is to assign a picture of car to the brand of picture.like in the drop down if a person select hyundai thena picture of hyundai brand car should get displayed.

any help will be appricated.

thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

create value node (image)

create value attributes imgalt

imgsource

define action and assign that action to Dropdown

on implemnetation of method onaction()

string img=wdcontext.node().currentnodeelement().getcartype(); //dropdown value

wdcontext.nodeimage().currentimageelement().setimgalt(img+".gif");

wdcontext.nodeimage().currentimageelement().setimgsource(img+".gif");

i hope this will work.

Thanks and Regards,

Tulasi Palnati

Former Member
0 Kudos

I tried the same code but i am not able to understand where i am going to define that image1 is for maruti image2 is for alto image3 is for bmw, and when i select alto from drop down it will only select the corresponding image2.where should i do the linking between the images and the names of cars in the drop down list.

Former Member
0 Kudos

Hi Rashami

insted of having image names like image1, image2,.... you can give image names like maruti, bmw, .... so whatever value you are getting from dropdown you can just concat it with .gif or whatever extention of the image and it will work

e. g.

when you select "Maruti" in drop down you will get it in img variable from bellow line

string img=wdcontext.node().currentnodeelement().getcartype();

Now there will be a image named as Maruti.gif so in bellow line you will get the perfect image name "Maruti.gif"

String imgName = img+".gif";

And then you assign this image name to the image node

wdcontext.nodeimage().currentimageelement().setimgalt(imgName);

wdcontext.nodeimage().currentimageelement().setimgsource(imgName);

Ninad

Former Member
0 Kudos

Hi Ninad,

I was really silly, was not able to understand the code, thanks for explaining me the concept.

Thanks a lot.It is working fine now.

Answers (3)

Answers (3)

Former Member
0 Kudos

Drop-down lists don't support icons. As an alternative, you could open a popup window or use a Menu UI element.

Or do you just want to display an image that corresponds to the current selection of the drop-down list? To do so, assign an action to the onSelect event and change the image source of some Image UI element according to the selection.

Armin

former_member201361
Active Contributor
0 Kudos

Hi,

Create a action say "onSelect" and bound this action to the onSelect property of thr drop down.

when the user selects the Hyundai , show the image of the car.

have all the images in the component mimes folder and create a context attribute of type String .

bound this attribute to the source property of the image ui element.

in the Action method :

get the current selected element and based on the condition set the path of the image to the attribute .

(if hyundai is selected , set the image path to the context attribute).

Thanks and regards

Former Member
0 Kudos

Hi,

Have a workaround like,,,

Set the source property of Image UI to Context Attribute and check the dropdown element and then set the image context attribute like

if(wdContext.CurrentDropdownelement.getAttr()=="MARUTHI")

{

IprivateView.Imageelement ele = wdContext.nodeImage().createImageelement();

ele.setImageAttri(" ......");

wdContext.nodeImage().bind(ele);

}

Regards

Raghu