Subsetting Embedded Data | XM Community
Skip to main content
Solved

Subsetting Embedded Data

  • December 13, 2018
  • 4 replies
  • 12 views

Hi all, Is it possible to subset embedded data, generally? And is it possible to do so for custom HTML code? In particular, I'm displaying photos with text beneath them as response options (each response looks like "<img src="..."/><p>...</p>"), participants select one of the responses, the selected response is saved as embedded data, and the the embedded data/selected response is later re-displayed for ratings (e.g., "How extraverted is this person?"). When I re-display the selected responses, I don't want to show the text originally displayed beneath them (i.e., <p>...</p>). Is it possible to subset the embedded data so as to display only the image portion of each response (i.e., <img src="..."/>)? Thanks

Best answer by TomG

@stephanoplis, You don't even need embedded variables. In your original choices (i.e., options), put the text inside a `<div>` with a class. For this example, let's call the class name 'choiceText'. So, the html for the choices look something like: ``` <img src="image1_url" alt="image1_description"><div class="choiceText">Text description1</div> <img src="image2_url" "alt_image2_description"><div class="choiceText">Text description2</div> etc. ``` Then in the follow-up question pipe the answer from the first question, and add JS to hide the text: ``` jQuery("#"+this.questionId+" div.choiceText").hide(); ```

4 replies

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+44
  • Level 6 ●●●●●●
  • December 13, 2018
You have to store only image part as embedded data and than have to use this embedded data in next question which will be image.

  • Author
  • December 13, 2018
Thanks. How do i that? Currently, I'm setting the embedded data using the "selected choice" option. Is there a way to grab only the image part when doing that? Or do I need to remove the paragraph/text portion from the response options?

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • December 13, 2018
@stephanoplis, You don't even need embedded variables. In your original choices (i.e., options), put the text inside a `<div>` with a class. For this example, let's call the class name 'choiceText'. So, the html for the choices look something like: ``` <img src="image1_url" alt="image1_description"><div class="choiceText">Text description1</div> <img src="image2_url" "alt_image2_description"><div class="choiceText">Text description2</div> etc. ``` Then in the follow-up question pipe the answer from the first question, and add JS to hide the text: ``` jQuery("#"+this.questionId+" div.choiceText").hide(); ```

  • Author
  • December 13, 2018
@TomG thanks so much! that solved it