Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Both horizontal and vertical single grid: Difference between revisions

From Catglobe Wiki
No edit summary
No edit summary
Line 3: Line 3:
There are a single grid question . Respondents should prioritize statements (sub questions) .  
There are a single grid question . Respondents should prioritize statements (sub questions) .  


<br>Example&nbsp;:  
== <br>Example&nbsp;: ==


I have a list of trade-mark and want the user to prioritize those list&nbsp;:  
I have a list of trade-mark and want the user to prioritize those list&nbsp;:  
Line 17: Line 17:
[[Image:Example 1.JPG]]<br>  
[[Image:Example 1.JPG]]<br>  


<br>Solution&nbsp;:  
== <br>Solution&nbsp;: ==


Use single grid question (statements as subquestion and ranks as answer option )  
Use single grid question (statements as subquestion and ranks as answer option )  
Line 23: Line 23:
<br>  
<br>  


Code  
== Code ==


The script makes a single grid question function as a single grid both horizontally and vertically.  
The script makes a single grid question function as a single grid both horizontally and vertically.  


<source lang="javascript" line="1">
option.prototype.getHTML = function(ltype) {  
option.prototype.getHTML = function(ltype) {  


Line 149: Line 150:
}  
}  


}<br><br>
}</source>

Revision as of 08:40, 2 March 2009

Chalenge :

There are a single grid question . Respondents should prioritize statements (sub questions) .


Example :

I have a list of trade-mark and want the user to prioritize those list :

Dell

Apple

IBM

FPT Elead



Solution :

Use single grid question (statements as subquestion and ranks as answer option )


Code

The script makes a single grid question function as a single grid both horizontally and vertically.

option.prototype.getHTML = function(ltype) { 

var stmp = ""; 

if(this.visible) { 

switch(ltype) { 

case 2: 

stmp += "&lt;input type=\"radio\" "; 

stmp += "name=\""+this.label+"\" "; 

stmp += "value=\""+this.value+"\" "; 

if(this.checked) stmp += "checked "; 

if(this.disabled) stmp += "disabled "; 

stmp += "onclick=\"myoptclick('"+this.label+"',"+this.index+",false);\"&gt;"; 

return "&lt;td valign=\"center\" align=\""+this.align+"\"&gt;"+stmp+"&lt;/td&gt;";; 

break; 

} 

} 

} 

quest.next = nextTest; 

function nextTest() { 

// initialise check array 

var arrIndexUsed = new Array(); 

for (i=0;i&lt;quest.questions[0].options.length;i++) { 

arrIndexUsed[i] = false; 

} 

// loop through options and check for double used options 

for (i=0;i&lt;quest.questions.length;i++) { 

for (j=0;j&lt;quest.questions[i].options.length;j++) { 

if (quest.questions[i].options[j].checked) { 

arrIndexUsed[j] = true; 

} 

} 

} 

// loop through possible answer options and check that all are used 

for (i=0;i&lt;arrIndexUsed.length;i++) { 

if (&nbsp;! arrIndexUsed[i] ) { 

alert('All options must used'); 

return false; 

} 

} 

buttonsStatus(true); 

document["query"]["dir"].value = "next"; 

return true; 

} 

function myoptclick(slbl, lidx, blnk) { 

optclick(slbl, lidx, blnk); 

for (i=0;i&lt;quest.questions.length;i++) { 

if ( quest.questions[i].label&nbsp;!= slbl ) { 

quest.questions[i].options[lidx].checked = false; 

o1 = document["query"][quest.questions[i].label]; 

cb = o1; 

cb[lidx].checked = false; 

} 

else { 

for (j=0;j&lt;quest.questions[i].options.length;j++) { 

quest.questions[i].options[j].checked = false; 

} 

quest.questions[i].options[lidx].checked = true; 

o1 = document["query"][quest.questions[i].label]; 

cb = o1; 

cb[lidx].checked = true; 

} 

} 

}