From e68d8bf088e59c43a62371622cb7fd2478cc755f Mon Sep 17 00:00:00 2001 From: Xiaolu Bai Date: Wed, 25 Jan 2017 19:14:51 -0800 Subject: [PATCH] fixes value empty issue with quoted string --- plugins/jspsych-survey-multi-choice.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/plugins/jspsych-survey-multi-choice.js b/plugins/jspsych-survey-multi-choice.js index 13de8e23..14125d33 100644 --- a/plugins/jspsych-survey-multi-choice.js +++ b/plugins/jspsych-survey-multi-choice.js @@ -112,14 +112,24 @@ jsPsych.plugins['survey-multi-choice'] = (function() { display_element.querySelector(question_selector).innerHTML += '
'; // add label and question text - var option_label = ''; - display_element.querySelector(option_id_selector).innerHTML += option_label; - - // create radio button + var form = document.getElementById(option_id_name) var input_id_name = _join(plugin_id_name, 'response', i); - display_element.querySelector(option_id_selector + " label").innerHTML = - '' + - display_element.querySelector(option_id_selector + " label").innerHTML; + var label = document.createElement('label'); + label.setAttribute('class', plugin_id_name+'-text'); + label.innerHTML = trial.options[i][j]; + label.setAttribute('for', input_id_name) + // var option_label = ''; + // display_element.querySelector(option_id_selector).innerHTML += option_label; + // create radio button + var input = document.createElement('input'); + input.setAttribute('type', "radio"); + input.setAttribute('name', input_id_name); + input.setAttribute('value', trial.options[i][j]) + form.appendChild(input); + form.appendChild(label) + // display_element.querySelector(option_id_selector + " label").innerHTML = + // '' + + // display_element.querySelector(option_id_selector + " label").innerHTML; } if (trial.required && trial.required[i]) {