jhylands

Set up

Dec 20th, 2013
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include 'head.php';
  3. ?>
  4. <script language="Javascript">
  5. function SelectMoveRows(SS1,SS2)
  6. {
  7.     var SelID='';
  8.     var SelText='';
  9.     // Move rows from SS1 to SS2 from bottom to top
  10.     for (i=SS1.options.length - 1; i>=0; i--)
  11.     {
  12.         if (SS1.options[i].selected == true)
  13.         {
  14.             SelID=SS1.options[i].value;
  15.             SelText=SS1.options[i].text;
  16.             var newRow = new Option(SelText,SelID);
  17.             SS2.options[SS2.length]=newRow;
  18.             SS1.options[i]=null;
  19.         }
  20.     }
  21.     //SelectSort(SS2);
  22. }
  23. function moveUp(SS1)
  24. {
  25.     var SelID='';
  26.     var SelText='';
  27.     // Move rows from SS1 to SS2 from bottom to top
  28.     for (i=0; i<=SS1.options.length - 1; i++)
  29.     {
  30.         if (SS1.options[i].selected == true)
  31.         {
  32.             //check that the move is valid i.e the item is not at the top of the list
  33.             if(i!=0){
  34.             // Swap down(moving up the list)
  35.             ID=SS1[i].value;
  36.             Text=SS1[i].text;
  37.             SS1[i].value=SS1[i-1].value;
  38.             SS1[i].text=SS1[i-1].text;
  39.             SS1[i-1].value=ID;
  40.             SS1[i-1].text=Text;
  41.             SS1.options[i].selected = false;
  42.             SS1.options[i-1].selected = true;
  43.             }else{
  44.             //tell the user there was an error
  45.             alert('One of the items was already at the top of the list!');
  46.             }
  47.         }
  48.     }
  49. }
  50. function moveDown(SS1)
  51. {
  52.     var SelID='';
  53.     var SelText='';
  54.     // Move rows from SS1 to SS2 from bottom to top
  55.     for (i=SS1.options.length - 1; i>=0; i--)
  56.     {
  57.         if (SS1.options[i].selected == true)
  58.         {
  59.             //check if the move is valid i.e. if the item is not at the bottom of the list
  60.             if(i!==SS1.options.length-1){
  61.             // Swap down(moving up the list)
  62.             ID=SS1[i].value;
  63.             Text=SS1[i].text;
  64.             SS1[i].value=SS1[i+1].value;
  65.             SS1[i].text=SS1[i+1].text;
  66.             SS1[i+1].value=ID;
  67.             SS1[i+1].text=Text;
  68.             SS1.options[i].selected = false;
  69.             SS1.options[i+1].selected = true;
  70.             }else{
  71.             //tell the user there was an error
  72.             alert('One of the items you have selected is already at the bottom of the list!');
  73.             }
  74.         }
  75.     }
  76. }
  77. function SelectSort(SelList)
  78. {
  79.     var ID='';
  80.     var Text='';
  81.     for (x=0; x < SelList.length - 1; x++)
  82.     {
  83.         for (y=x + 1; y < SelList.length; y++)
  84.         {
  85.             if (SelList[x].text > SelList[y].text)
  86.             {
  87.                 // Swap rows
  88.                 ID=SelList[x].value;
  89.                 Text=SelList[x].text;
  90.                 SelList[x].value=SelList[y].value;
  91.                 SelList[x].text=SelList[y].text;
  92.                 SelList[y].value=ID;
  93.                 SelList[y].text=Text;
  94.             }
  95.         }
  96.     }
  97. }
  98. </script>
  99. <div style="position:relative;top:100px;">
  100. <form name="Example">
  101. <center>
  102. <table border="0" cellpadding="3" cellspacing="0">
  103.     <tr>
  104.         <td>
  105.             <h2>What group does this rule apply to?</h2>
  106.             <label for="year">Year:</label>
  107.             <select id="year">
  108.                 <option value="1">All years</option>
  109.                 <option value="2">Lower school (years:7,8,9,10,11)</option>
  110.                 <option value="3">KS3 (years:7,8,9)</option>
  111.                 <option value="4">KS4 (years:10,11)</option>
  112.                 <option value="5">Sixth form (years:12,13)</option>
  113.                 <?php for($i=7;$i<=13;$i++){echo "<option value='" . $i ."'>Year " . $i . "</option>";}?>
  114.             </select>
  115.             <br />
  116.             <label for="subject">Subject:</label>
  117.             <select id="subject">
  118.                 <option value="0">All subjects</option>
  119.                 <option value="1">Arts</option>
  120.                 <option value="2">Sciences</option>
  121.                 <option value="3">Humanities</option>
  122.             <select>
  123.             <hr />
  124.             <label for="class">OR a specific class:</label>
  125.             <input type="text" id="class" /><br/>
  126.         </td>
  127.         <td></td>
  128.         <td width="510px">
  129.             <p class="information">Select the questions from the past that you want to use with each subject. Once you are done click select questions and the questions in the 'to be used' box will be assigned.</p>
  130.             <input type="button" value="Select questions" />
  131.         </td>
  132.     </tr>
  133.     <tr>
  134.         <td>
  135.             <select name="allQuestions" size="10" style="width:500px;" MULTIPLE>
  136.             <?php
  137.                 include 'scripts/sql.php';
  138.                 $QRY0 = "SELECT * FROM questions ORDER BY 'PID' ASC";
  139.                 $results = mysqli_query($con,$QRY0);
  140.                 while($row = mysqli_fetch_array($results)){
  141.                     echo "<option value='" . $row['PID'] . "'>". $row['Question'] . "</option>";
  142.                 }
  143.             ?>
  144.             </select><br />
  145.             <input type="text" > <input type="button" value="Add Question" />
  146.         </td>
  147.         <td align="center" valign="middle">
  148.             <input type="Button" value="Add >>" style="width:100px" onClick="SelectMoveRows(document.Example.allQuestions,document.Example.selectedQuestions)"><br>
  149.             <br>
  150.             <input type="Button" value="<< Remove" style="width:100px" onClick="SelectMoveRows(document.Example.selectedQuestions,document.Example.allQuestions)">
  151.         </td>
  152.         <td>
  153.             <select name="selectedQuestions" size="10" style="width:500px;" MULTIPLE>
  154.             </select>
  155.             <br /><input type="button" value="Move question up" onclick="moveUp(document.Example.selectedQuestions)" /><input type="button" value="Move question down" onclick="moveDown(document.Example.selectedQuestions)"/>
  156.         </td>
  157.     </tr>
  158.  
  159. </table>
  160. </center>
  161. </form>
  162. </div>
  163. </body>
  164. </html>
Advertisement
Add Comment
Please, Sign In to add comment