• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How to Create a RadioButton Matrix for Ranking

How to Create a RadioButton Matrix for Ranking 8 years 2 months ago #36439

I ave a question on a survey form as follows:
Being given a specific task to perform under someone else's direction(*) ■ 1 ■ 2 ■ 3 ■ 4
Designing and carrying out a project by myself.(*) ■ 1 ■ 2 ■ 3 ■ 4
Working as a member of a group or team(*) ■ 1 ■ 2 ■ 3 ■ 4
Taking responsibility for managing a project with a group of people.(*) ■ 1 ■ 2 ■ 3 ■ 4

I want people to rank these statements from 1 to 4. that means that I only want rank 1 to be checked once in column 1 and 2 once in column 2 and 3 once in column 3 and 4 once ion column 4.

I am having trouble getting the jQuery to work to solve this. Any idea?

You can view the form at: https://911tap.org/join-us/take-the-petitioner-s-survey
Last Edit: 8 years 2 months ago by webdevtim. Reason: Add a link
The administrator has disabled public write access.

How to Create a RadioButton Matrix for Ranking 8 years 2 months ago #36449

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

You can try these steps:

- firstly rename your radio groups slightly so that the script is simplified (notice instead of the last letter it will have an underscore and a number):

Instead of tap_survey_question_3a use tap_survey_question_3_0
Instead of tap_survey_question_3b use tap_survey_question_3_1
...and so on for the other remaining 2.

- edit each radio group > Attributes > Additional Attributes area and add the following snippet (all will have the same trigger):
onclick="radioMatrix(this.id);"

- finally add the JavaScript (while editing a form > Properties > CSS and JavaScript > JavaScript), including the <script> tags:
<script type="text/javascript">
function radioMatrix(id){
	radSel = id.slice(-1);
	radGroupsName = id.slice(0, -2);
	radGroupId = id.slice(-2, -1);
	for(i = 0; i < 4; i++){
		if(parseInt(radGroupId) != i){
			document.getElementById(radGroupsName+i+radSel).checked = false;
		}
	}
}
</script>
This is not official customer support. To receive your support, submit a support ticket here.
Last Edit: 8 years 2 months ago by adrianp. Reason: emphasising
The administrator has disabled public write access.

How to Create a RadioButton Matrix for Ranking 8 years 2 months ago #36469

Thank you very much for this simple solution.

What I tried to do was create the same thing only using the letter designations instead of numerals so that the existing fields would be disturbed.

My id names would have looked like:
id="tap_survey_question_3a0"
id="tap_survey_question_3a1"
id="tap_survey_question_3a2"
id="tap_survey_question_3a3"
I would use the same function call in the "Additional Attributes"
onclick="radioMatrix(this.id);"

- and I would have added the JavaScript (while editing a form > Properties > CSS and JavaScript > JavaScript), including the <script> tags:

But the function would have looked slightly different:
<script type="text/javascript">
function radioMatrix(id){
        radTestGroupIds = "abcd";
	radSel = id.slice(-1);
	radGroupsName = id.slice(0, -2);
	radGroupId = id.slice(-2, -1);
	for(i = 0; i < 4; i++){
		if(radGroupId != radTestGroupIds.charAt(i)){
			document.getElementById(radGroupsName+radTestGroupIds.charAt(i)+radSel).checked = false;
		}
	}
}
</script>

Unfortunately, though this seems like it would work to me, it didn't.
Last Edit: 8 years 2 months ago by webdevtim. Reason: Saw more typos
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!