Created
September 14, 2018 15:18
-
-
Save carmoreira/5dc110e925a2d8cf7d866ae438e4dff0 to your computer and use it in GitHub Desktop.
Convert answers from Advisor Quiz list into dropdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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