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

reverse order of options according to device type

  • 26 June 2023
  • 4 replies
  • 105 views

Userlevel 4
Badge +16

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!

icon

Best answer by Tom_1842 26 June 2023, 17:21

View original

4 replies

Userlevel 7
Badge +27

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

Userlevel 4
Badge +16

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 

Userlevel 7
Badge +27

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.

Userlevel 4
Badge +16

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

Have a nice day!

Leave a Reply