Forum Discussion

ShannonPage-27d's avatar
ShannonPage-27d
Community Member
10 days ago

Magic JavaScript switch?

I have a drag and drop quiz with 95 drag options that are then added to a chart. This is all working beautifully and tiling onto the chart very nicely, but if I want to randomize the order that the 95 options appear in (on the drag sequence menu) then I have to manually drag them around to make them appear randomized. 

Has anyone ever incorporated javascript to make drag options appear in random order if they are appearing one by one? 

Apologies if this is unclear or not allowed to ask.

 

  • I don't think you can do that. I looked into it briefly and it seems the order is set either upon publishing, or before the page elements are manipulatable by user JavaScript. Rearranging the published draggable objects does not help, and forcibly reordering the object references appearsto break the functionality.

  • Nedim's avatar
    Nedim
    Community Member

    I might have developed something similar a while back. It was an experiment that I had to stop working on due to time constraints. It's a basic drag-and-drop interaction where drag items appear in a random sequence order based on their z-index. The script used identifies all elements with a "data-acc-text" attribute that contains the word "DRAG" and treats them as draggable items. It generates a random z-index for each drag item, which determines the stacking order. This randomization is done each time an object "disappears" and then "reappears" (when one item disappears, the script assigns a new z-index to all items before showing the next item). Please check the attached video for a brief demonstration. However, I'm not entirely sure if this is exactly what you're looking for.