reverse order of options according to device type | XM Community
Skip to main content
Solved

reverse order of options according to device type

  • June 26, 2023
  • 4 replies
  • 189 views

Ricmarug
Level 5 ●●●●●
Forum|alt.badge.img+16
  • Level 5 ●●●●●
  • 61 replies

Hello!

We have a 1-5 scale in a CES question and we would like it to have the 5 on the top for mobile and the 5 to the right in desktop. For example, if we use the 1-5 order, we have the right view in desktop (1 to the left and 5 to the right) but not in mobile. 

Is it possible to define the order based on the device type? 

Thanks!

Best answer by Tom_1842

Hi, try using this script developed by TomG. I found it in this post

4 replies

Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 909 replies
  • Answer
  • June 26, 2023

Hi, try using this script developed by TomG. I found it in this post


Ricmarug
Level 5 ●●●●●
Forum|alt.badge.img+16
  • Author
  • Level 5 ●●●●●
  • 61 replies
  • June 26, 2023

It worked perfectly!!

Would you mind giving me a really simple explanation of whar does the code do? or how does it work? I was expecting some “device type” variable or something like that but I don’t really understand what is happening there 😅

Than you so much, @Tom_1842 


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 909 replies
  • June 26, 2023

In that other thread, TomG mentions how the mobile view turns the answer choices to vertical:

In HTML, the choices are a table row with cells in left to right order. To make it vertical Qualtrics uses a @media CSS rule so when the screen width is 480px or less it changes the cells to display:block which makes them vertical but doesn't change the order.

In TomG’s JavaScript, the first 2 lines look for the table row and the answer choices.

If the answer choices are set to display:block (which only happens if they are displayed vertically with mobile), then loop through each cell and 'prepend' them to the table row. As each choice gets prepended, it gets placed at the beginning of the list, finishing with the last answer option which then displays first to the respondent.


Ricmarug
Level 5 ●●●●●
Forum|alt.badge.img+16
  • Author
  • Level 5 ●●●●●
  • 61 replies
  • June 26, 2023

It’s very clear now, thank you again for taking the time to explain this. 

Have a nice day!