Ignore:
Timestamp:
09/19/11 16:29:02 (14 years ago)
Author:
fpvanagthoven
Message:

Code to get questions and put them in objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/QuestionCreationTool.php

    r108 r112  
    244244                categoryBox.appendChild(categoryInput);
    245245            }
    246                                                                    
     246                       
     247            function clearFields()
     248            {
     249                clearCategory();
     250                clearCode();
     251                clearTitle();
     252                clearDescription();
     253                clearType();
     254            }
     255           
     256            function clearCategory()
     257            {
     258                var categoryBox = document.getElementById("categoryBox");
     259                categoryBox.innerHTML = "";
     260               
     261                var questionCategorySelect = document.createElement("select");
     262                questionCategorySelect.setAttribute("name", "questionCategory");
     263                questionCategorySelect.id = "questionCategorySelect";
     264               
     265                var newCategoryButton = document.createElement("input");
     266                newCategoryButton.setAttribute("type", "button");
     267                newCategoryButton.setAttribute("onclick", "newCategory()");
     268                newCategoryButton.setAttribute("value", "New Category");
     269                newCategoryButton.className = "surveyButton";
     270               
     271                categoryBox.appendChild(questionCategorySelect);
     272                categoryBox.appendChild(newCategoryButton);
     273            }
     274           
     275            function clearCode()
     276            {
     277                var codeInput = document.getElementById("questionCode");
     278                codeInput.value = "";
     279            }
     280           
     281            function clearTitle()
     282            {
     283                var titleInput = document.getElementById("questionTitle");
     284                titleInput.value ="";
     285            }
     286           
     287            function clearDescription()
     288            {
     289                var descriptionInput = document.getElementById("questionDescription");
     290                descriptionInput.value = "";
     291            }
     292           
     293            function clearType()
     294            {
     295                var typeSelect = document.getElementById("questionTypeSelect");
     296                typeSelect.selectedIndex = 0;
     297            }
     298           
    247299        </script>
    248300        <?php
     
    273325                    <td><label for="questionCategory">Category</label></td>
    274326                    <td id="categoryBox"><!-- Select should be filled with existing categories-->
    275                         <select name="questionCategory">
     327                        <select id="questionCategorySelect" name="questionCategory">
    276328                            <option value='Test Category'>Test Category</option>
    277329                        </select>
     
    295347                    <td><label for="questionType">Type answer</label></td>
    296348                    <td id="questionType">
    297                         <select name="questionType" onchange="handleType(this)">
     349                        <select id="questionTypeSelect" name="questionType" onchange="handleType(this)">
    298350                            <option value='text' selected='selected'>Text</option>
    299351                            <option value='int'>Integer</option>
     
    306358            </table>
    307359            <div id="answerSpecifications"></div>
     360            <input id="clearQuestionFields" type="button" onclick="clearFields()" class="surveyButton" value="Clear" />
    308361            <input id="saveQuestion" type="submit" class="surveyButton" value="Save" />
    309362        </form>
Note: See TracChangeset for help on using the changeset viewer.