- Timestamp:
- 07/18/11 17:16:31 (14 years ago)
- Location:
- Dev/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SurveyCreationTool.php
r18 r19 19 19 SurveyCreationTool::questionCreationForm(); 20 20 SurveyCreationTool::addQuestionButton(); 21 SurveyCreationTool::removeLastQuestionButton(); 21 22 SurveyCreationTool::submitButton(); 22 23 ?></form></div> … … 28 29 <script type="text/javascript"> 29 30 var questionCount = 1; 30 31 31 32 function getNewQuestion() 32 33 { … … 51 52 "<div id='answersDiv" + questionCount + "'></div>" + 52 53 "</div>"; 53 54 54 55 questionDiv.innerHTML = htmlStr; 55 56 56 57 return questionDiv; 57 58 } 58 59 59 60 function handleFocus(input) 60 61 { … … 66 67 } 67 68 } 68 69 69 70 function handleBlur(input) 70 71 { 71 72 var surveyTitle = document.getElementById('surveyTitle'); 72 73 var surveyDescription = document.getElementById('surveyDescription'); 73 74 74 75 if (input.value == "") 75 76 { 76 77 input.style.color = "gray"; 77 78 input.clicked = null; 78 79 79 80 if (input == surveyTitle) 80 81 { … … 87 88 } 88 89 } 89 90 90 91 function handleType(select) 91 92 { … … 94 95 answersDiv.answerCount = 1; 95 96 answersDiv.clicked = null; 96 97 97 98 switch (type) { 98 99 case 'mc': 99 100 answersDiv.innerHTML = ""; 100 101 addOption(select.id); 101 102 102 103 break; 103 104 case 'text': … … 116 117 answersDiv.innerHTML = ""; 117 118 //what scale (min max incr) 119 minMaxIncr(select.id); 118 120 break; 119 121 default: … … 122 124 123 125 } 124 125 126 127 126 128 function addOption(questionNumber) 127 129 { … … 130 132 var answerDiv = document.createElement("div"); 131 133 answerDiv.className = "answerDiv"; 132 134 133 135 var htmlStr = "<input type='text' name='q" + 134 136 questionNumber + "ans" + answerCount + "' value='Option " + answerCount + "' />"; 135 137 136 138 if (answersDiv.clicked == null) 137 139 { … … 140 142 answersDiv.clicked = true; 141 143 } 142 144 143 145 answerDiv.innerHTML = htmlStr; 144 146 145 147 answersDiv.appendChild(answerDiv); 146 148 answersDiv.answerCount++; 147 149 } 148 150 149 151 function minMax(questionNumber) 150 152 { 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 153 var answersDiv = document.getElementById("answersDiv" + questionNumber); 154 155 var answerDiv = document.createElement("div"); 156 answerDiv.className = "answerDiv"; 157 answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' name='min" + questionNumber + "' />" + 158 "<label for='max'>Max</label><input type='text' name='max" + questionNumber + "' />"; 159 158 160 answersDiv.appendChild(answerDiv); 159 } 160 161 } 162 163 function minMaxIncr(questionNumber) 164 { 165 minMax(questionNumber); 166 var answersDiv = document.getElementById("answersDiv" + questionNumber); 167 168 var answerDiv = document.createElement("div"); 169 answerDiv.className = "answerDiv"; 170 answerDiv.innerHTML = "<label for='incr'>Increment by</label><input type='text' name='incr" + questionNumber + "' />"; 171 172 answersDiv.appendChild(answerDiv); 173 } 174 175 161 176 function addQuestion() 162 177 { 163 178 var questionsDiv = document.getElementById('questionsDiv'); 164 179 var newQuestion = getNewQuestion(); 165 180 181 182 newQuestion.prev = document.lastQuestion; 183 document.lastQuestion = newQuestion; 184 166 185 questionsDiv.appendChild(newQuestion); 167 186 questionCount++; 168 187 } 169 170 188 189 function removeLastQuestion() 190 { 191 var questionsDiv = document.getElementById('questionsDiv'); 192 193 if (document.lastQuestion.prev != null) 194 { 195 questionsDiv.removeChild(document.lastQuestion); 196 document.lastQuestion = document.lastQuestion.prev; 197 questionCount--; 198 } 199 else 200 { 201 // do nothing 202 } 203 } 204 205 206 171 207 </script> 172 208 <?php … … 199 235 } 200 236 237 private static function removeLastQuestionButton() { 238 ?> 239 <input type="button" onclick="removeLastQuestion()" value="x" class="surveyButton" /> 240 <?php 241 } 242 201 243 private static function submitbutton() { 202 244 ?> -
Dev/trunk/css/style.css
r17 r19 140 140 141 141 .question { 142 margin-top: 1em; 142 margin-top: 3em; 143 border-top: 1px solid #ddd; 143 144 } 144 145
Note: See TracChangeset
for help on using the changeset viewer.