Difference between revisions of "Make whole cell clickable in single and multi grids"

From Catglobe Wiki
Jump to: navigation, search
(Challenge)
Line 1: Line 1:
 
== Challenge ==  
 
== Challenge ==  
 
Normally, the grid question require a click on the checkbox or radiobutton. Now, we want it to register the answer when the user click on the cell for the answer option.
 
Normally, the grid question require a click on the checkbox or radiobutton. Now, we want it to register the answer when the user click on the cell for the answer option.
 
+
<br>
== Example ==
+
'''Example'''<br>
 
[[Image:Clickable_cell.gif ]]
 
[[Image:Clickable_cell.gif ]]
 +
== Solution ==
 +
*Create a grid question
 +
*Add the below script to that question
  
== Script ==  
+
== Code ==  
 
<source lang="javascript" line="1">
 
<source lang="javascript" line="1">
 
quest.onInit = function()
 
quest.onInit = function()
Line 20: Line 23:
  
 
</source>
 
</source>
 +
== Source ==
 +
Questionnaire Resource Id on cg.catglobe.com site: 164079 (Question: Q10_Make_whole_cell_clickable_in_single_and_multi_)

Revision as of 05:16, 6 February 2012

Challenge

Normally, the grid question require a click on the checkbox or radiobutton. Now, we want it to register the answer when the user click on the cell for the answer option.
Example
Clickable cell.gif

Solution

  • Create a grid question
  • Add the below script to that question

Code

 1 quest.onInit = function()
 2 {
 3    $(".grid_subquestion_odd,.grid_subquestion_even").click(
 4             function(evt)
 5             {
 6                if(evt.target.nodeName == "INPUT")
 7                   return true;
 8                $(this).children("input").click();
 9                return false;
10             });
11  }

Source

Questionnaire Resource Id on cg.catglobe.com site: 164079 (Question: Q10_Make_whole_cell_clickable_in_single_and_multi_)