summaryrefslogtreecommitdiffstats
path: root/src/demos/survey.html
blob: d4f8c3f5cda18ea3088048a080b4ac318a0d2b64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
	<head> 
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>jQuery Impromptu States Survey Example</title>
		
		<link rel="stylesheet" media="all" type="text/css" href="../jquery-impromptu.css" />
		
		<style type="text/css">			
			/*-------------------------------- */
            div.jqi .jqimessage .field{ padding: 2px 0; }
			div.jqi .jqimessage .field textarea{ width: 100%; height: 120px; }
			/*-------------------------------- */
		</style>
		
		<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
		<script type="text/javascript" src="../jquery-impromptu.js"></script>

	
		<script type="text/javascript">
			function openprompt(){
			
				var temp = {
					state0: {
						html:'<p>How would you rate the content of this site?</p><div class="field"><input type="radio" name="rate_content" id="rate_content_poor" value="Poor" class="radioinput" /><label for="rate_content_poor">Poor</label></div><div class="field"><input type="radio" name="rate_content" id="rate_content_ok" value="Ok" class="radioinput" /><label for="rate_content_ok">Ok</label></div><div class="field"><input type="radio" name="rate_content" id="rate_content_good" value="Good" class="radioinput" /><label for="rate_content_good">Good</label></div><div class="field"><input type="radio" name="rate_content" id="rate_content_excellent" value="Excellent" class="radioinput" /><label for="rate_content_excellent">Excellent!</label></div>',
						buttons: { Cancel: false, Next: true },
						focus: 1,
						submit:function(e,v,m,f){ 
							if(!v)
								$.prompt.close()
							else $.prompt.goToState('state1');//go forward
							return false; 
						}
					},
					state1: {
						html:'<p>Check all which need improvement:</p><div class="field"><input type="checkbox" name="rate_improve" id="rate_improve_colors" value="Color Scheme" class="radioinput" /><label for="rate_improve_colors">Color Scheme</label></div><div class="field"><input type="checkbox" name="rate_improve" id="rate_improve_graphics" value="Graphics" class="radioinput" /><label for="rate_improve_graphics">Graphics</label></div><div class="field"><input type="checkbox" name="rate_improve" id="rate_improve_readability" value="readability" class="radioinput" /><label for="rate_improve_readability">Readability</label></div><div class="field"><input type="checkbox" name="rate_improve" id="rate_improve_content" value="Content" class="radioinput" /><label for="rate_improve_content">Content</label></div><div class="field"><input type="checkbox" name="rate_improve" id="rate_improve_other" value="Other" class="radioinput" /><label for="rate_improve_other">Other</label> <input type="text" name="rate_improve_other_txt" id="rate_improve_other_txt" value="" /></div>',
						buttons: { Back: -1, Cancel: 0, Next: 1 },
						focus: 2,
						submit:function(e,v,m,f){
							if(v==0)
								$.prompt.close()
							else if(v==1)
								$.prompt.goToState('state2');//go forward
							else if(v=-1)
								$.prompt.goToState('state0');//go back
							return false; 
						}
					},
					state2: {
						html:'How did you first find out about this site?<div class="field"><select name="rate_find" id="rate_find"><option value="Search">Search</option><option value="Online Publication">Online Publication</option><option value="friend">A Friend</option><option value="No Clue">No Clue</option></select></div>',
						buttons: { Back: -1, Cancel: 0, Next: 1 },
						focus: 2,
						submit: function(e, v, m, f){
							if (v == 0) 
								$.prompt.close()
							else 
								if (v == 1) 
									$.prompt.goToState('state3');//go forward
								else 
									if (v = -1) 
										$.prompt.goToState('state1');//go back
							return false;
						}
					},
					state3: {
						html:'<p>Please leave any other comments you have about this site:</p><div class="field"><textarea id="rate_comments" name="rate_comments"></textarea></div>',
						buttons: { Back: -1, Cancel: 0, Finish: 1 },
						focus: 2,
						submit:function(e,v,m,f){ 
							if(v==0) 
								$.prompt.close()
							else if(v==1)								
								return true; //we're done
							else if(v=-1)
								$.prompt.goToState('state2');//go back
							return false; 
						}
					}
				}
				
				$.prompt(temp,{
					close: function(e,v,m,f){
						if(v !== undefined){
							var str = "You can now process with this given information:<br />";
							$.each(f,function(i,obj){
								str += i + " - <em>" + obj + "</em><br />";
							});	
							$('#results').html(str);
						}
					}
				});
			}
		</script>
	</head>
	
	<body>
		<a href="javascript:openprompt()">Test Impromptu States Survey</a>
		<div id="results"></div>
	</body>
</html>