Using radio buttons to make a depression scale survey

Hi all, I’m trying to make a questionnaire/ survey using sets of radio button groups of 4, each button having a value ranging from 0-3. Once the survey is completed it needs to add up the total score and output something depending on what the user scored. Can this be done just with playing around in the database and connecting everything or do I need to actually code this?

here is our competition’s survey/ quiz (PHQ-9) for reference:
https://achievetms.com/depression/phq-9-depression-screening/

^ this. I need to do exactly this. Any help, thoughts, ideas would be greatly appreciated, Thanks!

Hi,
You can do that easily with a little bit of code, and we can help you with that.
First of all you can create the radio buttons with the wanted values, then create an onClick event for the submit button, calculate the sum of the radio buttons and show the relevant text (create hidden on load texts for each result)with a simple code like this:

export function submit_click(event, $w) {
	var sum =0;
	sum += $w("#radioGroup1").value;
	sum += $w("#radioGroup2").value;
	sum += $w("#radioGroup3").value;
	if (sum >0 && sum <=4){
		$w("#text1").show;
	}
	if (sum >4 && sum <=8){
		$w("#text2").show;
	}
	if (sum >8 && sum <=12){
		$w("#text3").show;
	}
}

Good luck :slight_smile:

You are awesome thank you so much!

Hello Or,

I want to do the same format of survey using 8 radio buttons with values. I use your solution but for me it didn´t work :frowning:

Can you or anyone of the community please help?

Thank you.