Skip to content

Instantly share code, notes, and snippets.

@carmoreira
Created September 14, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carmoreira/5dc110e925a2d8cf7d866ae438e4dff0 to your computer and use it in GitHub Desktop.
Save carmoreira/5dc110e925a2d8cf7d866ae438e4dff0 to your computer and use it in GitHub Desktop.
Convert answers from Advisor Quiz list into dropdown
//Replace question-1 with the number of your question
jQuery(document).ready(function(){
var select = jQuery('<select id="question-1-select"><option value="">Please Select</option></select>').on('change',function(){
var val = jQuery(this).val();
jQuery('ul[data-question-id="question-1"] input[data-value="'+val+'"]').click();
});
jQuery('ul[data-question-id="question-1"]').hide().after(select);
jQuery('ul[data-question-id="question-1"] li').each( function(){
var label = jQuery(this).find('label').text();
var value = jQuery(this).find('input').attr('data-value');
select.append('<option value="'+label+'">'+label+'</option>');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment