This article describes how to change images (e.g., brand logos) shown on a Page based on a Combo Box selection. The post contains the steps required to create a Page like this:
Requirements
- A Control Box (see How to Create a Combo Box Filter or How to Create a List Box Filter).
- A Conditional Image Visualization that changes based on the Control Box selection. See How to Create a Pictograph Conditional Image for further details.
- The URLs of the images you wish to display.
Method
- From the toolbar, go to Anything > Page Design > Control > Combo Box (Drop-Down) or List Box.
- With the control selected, go to the object inspector > Control > Item List and input the labels (e.g., brand names) you wish to appear in the list. All items in the list should be separated by a semi-colon (;).
- Still, in the object inspector, go to General > General > Name and input the desired name (e.g. brand.switch) to use later in the R code.
- In the toolbar select Calculation > Custom Code.
- Input the desired name of the calculation (e.g. current.brand) and set it to equal your combo box (i.e. brand.switch):
current.brand = brand.switch
To check the code is working, change the menu selection, and you should see the selection in the output update. - From the toolbar, select Visualization > Pictograph > Conditional Image.
- Change Data > Data Source > Data source to Use an Existing R Output.
- Click into Data > Data Source > Input data and select the calculation that you created in Step 5 (in this example it is called current.brand).
- From the Format tab, update Image type to Custom Images.
- Paste the URL of a default image. This image will appear in case no selections are made at the combo box.
- Each value contained in the combo box should appear in the Thresholds (ie: Threshold 1: DIsplayr; Threshold 2: Q).
- In each of the corresponding Image fields (Image 1, Image 2, etc.) enter the appropriate Image URL.
Next
How to Create a Pictograph Conditional Image
How to Create a Combo Box Filter
How to Dynamically Change a Question Based on a Control Box
How to Create a Combo Box (Drop-Down Control) With a Dynamic List