Changeset 18 for Dev/trunk/classes/SurveyCreationTool.php
- Timestamp:
- 07/15/11 21:15:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SurveyCreationTool.php
r17 r18 28 28 <script type="text/javascript"> 29 29 var questionCount = 1; 30 30 31 31 function getNewQuestion() 32 32 { … … 43 43 "<td><select id='" + questionCount + "' name='questionType" + questionCount + "' onchange='handleType(this)'><br />"+ 44 44 "<option value='text' selected='selected'>Text</option>" + 45 "<option value='multipleChoice'>Multiple choice</option>" + 45 "<option value='int'>Integer</option>" + 46 "<option value='mc'>Multiple choice</option>" + 46 47 "<option value='checkboxes'>Checkboxes</option>" + 47 48 "<option value='scale'>Scale</option>" + 48 "<option value='grid'>Grid</option>" +49 49 "</select></td></tr>" + 50 50 "</table>" + 51 51 "<div id='answersDiv" + questionCount + "'></div>" + 52 52 "</div>"; 53 53 54 54 questionDiv.innerHTML = htmlStr; 55 55 56 56 return questionDiv; 57 57 } 58 58 59 59 function handleFocus(input) 60 60 { … … 66 66 } 67 67 } 68 68 69 69 function handleBlur(input) 70 70 { 71 71 var surveyTitle = document.getElementById('surveyTitle'); 72 72 var surveyDescription = document.getElementById('surveyDescription'); 73 73 74 74 if (input.value == "") 75 75 { 76 76 input.style.color = "gray"; 77 77 input.clicked = null; 78 78 79 79 if (input == surveyTitle) 80 80 { … … 87 87 } 88 88 } 89 89 90 90 function handleType(select) 91 91 { … … 94 94 answersDiv.answerCount = 1; 95 95 answersDiv.clicked = null; 96 96 97 97 switch (type) { 98 case 'm ultipleChoice':98 case 'mc': 99 99 answersDiv.innerHTML = ""; 100 100 addOption(select.id); 101 101 102 102 break; 103 103 case 'text': 104 104 answersDiv.innerHTML = ""; 105 105 break; 106 case 'int': 107 answersDiv.innerHTML = ""; 108 //min max 109 minMax(select.id); 106 110 break; 107 111 case 'checkboxes': 108 answersDiv.innerHTML = ""; 112 answersDiv.innerHTML = ""; 113 addOption(select.id); 109 114 break; 110 115 case 'scale': 111 answersDiv.innerHTML = ""; 112 break; 113 case 'grid': 114 answersDiv.innerHTML = ""; 116 answersDiv.innerHTML = ""; 117 //what scale (min max incr) 115 118 break; 116 119 default: … … 119 122 120 123 } 124 121 125 122 123 126 function addOption(questionNumber) 124 127 { … … 127 130 var answerDiv = document.createElement("div"); 128 131 answerDiv.className = "answerDiv"; 129 132 130 133 var htmlStr = "<input type='text' name='q" + 131 134 questionNumber + "ans" + answerCount + "' value='Option " + answerCount + "' />"; 132 135 133 136 if (answersDiv.clicked == null) 134 137 { … … 137 140 answersDiv.clicked = true; 138 141 } 139 142 140 143 answerDiv.innerHTML = htmlStr; 141 144 142 145 answersDiv.appendChild(answerDiv); 143 146 answersDiv.answerCount++; 144 147 } 145 146 148 149 function minMax(questionNumber) 150 { 151 var answersDiv = document.getElementById("answersDiv" + questionNumber); 152 153 var answerDiv = document.createElement("div"); 154 answerDiv.className = "answerDiv"; 155 answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' name='min" + questionNumber + "' />" + 156 "<label for='max'>Max</label><input type='text' name='max" + questionNumber + "' />"; 157 158 answersDiv.appendChild(answerDiv); 159 } 160 147 161 function addQuestion() 148 162 { 149 163 var questionsDiv = document.getElementById('questionsDiv'); 150 164 var newQuestion = getNewQuestion(); 151 165 152 166 questionsDiv.appendChild(newQuestion); 153 167 questionCount++; 154 168 } 155 169 170 156 171 </script> 157 172 <?php
Note: See TracChangeset
for help on using the changeset viewer.