Default Radio Button | XM Community
Skip to main content

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

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


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


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
});


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


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