Autopunch answer to matrix question from previous single answer question | XM Community
Skip to main content

I have a project that I need to replace the old question (single row matrix table question) to a new one (multiple choice - single answer question). We don’t want to fully delete the old question as there are automations that are dependent on this. So, we wanted to simply copy the response from the new question and have it autocoded to the old one.

 

My challenge right now is I don’t know how to do this via javascript.

Hi Kenl,

I’m assuming your setup as:
 

if your both questions recode are same (single select answer options recode and grid scale options recode) and setup looks like this. Then you can keep both question on same page and hide the old question using JS. Please refer below code for hide and punch.

please note: read comment next to each code line for more clarity.


please replace QID33 with new question ID and QID34 with Old Question ID in below code.

	jQuery("#QID34").hide(); // hide Old question
jQuery("#NextButton").click(function(){
var inputX = jQuery("#QID33 inputitype='radio']:checked").val(); // record the selected radio value
var clX= '.QR-QID34-1-' + inputX; // create selector for old question to punch the new question value
jQuery(clX).prop("checked", true); // punch old question
});

 


Thank you @ArunDubey - this works perfectly!


Leave a Reply