Default Radio Button | XM Community
Skip to main content

Default Radio Button

  • September 12, 2022
  • 5 replies
  • 250 views

Forum|alt.badge.img+2

I have a Radio Button with Values Yes and No. How do I write a Java Script to Show the values 'Yes' by default.

5 replies

CarolK
Level 5 ●●●●●
Forum|alt.badge.img+42
  • Level 5 ●●●●●
  • 406 replies
  • September 12, 2022

You don't need Javascript to accomplish this. This is found under Question behavior - you can set a default choice.
image.png


Forum|alt.badge.img+2
  • Author
  • 2 replies
  • September 12, 2022

Hi Carol . With Default choices for Radio Buttons , the condition is failing in one of my display logic . When I close and open the browser , both 'Yes' and 'No' Radio Button gets selected . Hence want to use Java script


Forum|alt.badge.img+6
  • QPN Level 2 ●●
  • 40 replies
  • September 12, 2022

GuruRao If you want "Yes" to be default selected on page loads:
Add this onLoad -
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
 this.setChoiceValue(1,true) // 1 - Yes
});


Forum|alt.badge.img+2
  • Author
  • 2 replies
  • September 12, 2022

For some reason , both the radio buttons are getting selected . I cannot force it to show only one . Any help is appreciated.
image.JPG


CarolK
Level 5 ●●●●●
Forum|alt.badge.img+42
  • Level 5 ●●●●●
  • 406 replies
  • September 12, 2022

That actually sounds like a bug... if when you preview it after setting Default Choices, the selection does not work, the system is not doing what it is supposed to. I would suggest you open a ticket with Support for assistance. (They won't help you troubleshoot with JavaScript, but will send you back to the Community. But the Default Choices SHOULD be working, and THAT is something they should be able to escalate for resolution.


Leave a Reply