Subsetting Embedded Data | Experience Community
Skip to main content
Solved

Subsetting Embedded Data

  • Dec 13, 2018 12:33 AM UTC
  • 4 replies
  • 27 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(); ```
View original

4 replies

PeeyushBansal
Level 7 ●●●●●●●
Forum|alt.badge.img+52
  • Level 7 ●●●●●●●
  • Dec 13, 2018 12:55 AM UTC
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.

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
  • Dec 13, 2018 8:32 PM UTC
@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(); ```

@TomG thanks so much! that solved it