Side by side questions with logic between columns | XM Community
Solved

Side by side questions with logic between columns

  • 25 March 2020
  • 2 replies
  • 11 views

Hi!

I have a side by side question that has 2 columns:
* The first with Radio buttons where responders have to say if they have a characteristic (rows) - YES or NO
* The second is a free text field where they need to indicate a number.

In the case where the responder says no, I want to automatically populate the correspondent free text field with "0". This value should also be visible if the respondent submits the answer and then decides to return.

Is it possible to do? I'm really not comfortable with JS, especially regarding the manipulation of SbS questions.

Thanks!
Ana
icon

Best answer by rondev 25 March 2020, 16:02

View original

2 replies

Userlevel 7
Badge +22
Use the below code in the JS onReady of SBS question

jQuery("#"+this.questionId+" input[type='radio']").on('click',function(){
if(jQuery(this).val()==1){
jQuery(this).closest(".Choice ").find(".InputText").val('');
}else{
jQuery(this).closest(".Choice ").find(".InputText").val('0');
}
});
It works!!! Thanks!! 😀

Leave a Reply