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

From Catglobe Wiki
Jump to: navigation, search
(Created page with '== Challenge == Normally, the grid question require to click on the check or radiobutton. Now, we want it to register the answer when the user click on the cell. == Example == […')
 
(Example)
Line 2: Line 2:
 
Normally, the grid question require to click on the check or radiobutton. Now, we want it to register the answer when the user click on the cell.
 
Normally, the grid question require to click on the check or radiobutton. Now, we want it to register the answer when the user click on the cell.
 
== Example ==
 
== Example ==
[[Image:OneCheckRequired.png ]]
+
[[Image:Clickable_cell.gif ]]
 +
 
 
== Script ==  
 
== Script ==  
 
<source lang="javascript" line="1">
 
<source lang="javascript" line="1">

Revision as of 15:45, 27 January 2010

Challenge

Normally, the grid question require to click on the check or radiobutton. Now, we want it to register the answer when the user click on the cell.

Example

Clickable cell.gif

Script

 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  }