Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.61 KB | None | 0 0
  1. <?php
  2. $sv_name = "localhost";
  3. $username = "root";
  4. $password = "slash112bot";
  5. $db_name = "uni";
  6. ?>
  7. <script type="text/javascript">
  8. var psi1;
  9. var psi2;
  10. var psi3;
  11. var psi4;
  12.  
  13. //var xmlhttp;
  14.  
  15. var lvl;
  16. var sub1;
  17. var sub2;
  18. var sub3;
  19. var sub4;
  20.  
  21. var si1;
  22. var si2;
  23. var si3;
  24. var si4;
  25.  
  26. var todisable;
  27.  
  28. var isvalid1;
  29. var isvalid2;
  30. var isvalid3;
  31. var isvalid4;
  32.  
  33. var tmpFunc;
  34.  
  35. //loaded();
  36.  
  37. function loaded()
  38. {
  39. if(window.XMLHttpRequest)
  40. {
  41. xmlhttp=new XMLHttpRequest();
  42. }
  43. else
  44. {
  45. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  46. }
  47. }
  48.  
  49. function ClearChoices()
  50. {
  51. document.getElementById('div1').style.display = 'none';
  52. document.getElementById('div2').style.display = 'none';
  53. document.getElementById('div3').style.display = 'none';
  54. document.getElementById('div4').style.display = 'none';
  55. document.getElementById('divTimetable').style.display = 'none';
  56. document.uniform.level.selectedIndex = 0;
  57. document.uniform.subject1.selectedIndex = 0;
  58. document.uniform.subject2.selectedIndex = 0;
  59. document.uniform.subject3.selectedIndex = 0;
  60. document.uniform.subject4.selectedIndex = 0;
  61. }
  62.  
  63. function typeChanged()
  64. {
  65. if(document.uniform.level.value == "1")
  66. {
  67. document.getElementById('div1').style.display = '';
  68. document.getElementById('div2').style.display = '';
  69. document.getElementById('div3').style.display = '';
  70. document.getElementById('div4').style.display = 'none';
  71. document.uniform.subject4.selectedIndex = 0;
  72. }
  73. else if(document.uniform.level.value == "2")
  74. {
  75. document.getElementById('div1').style.display = '';
  76. document.getElementById('div2').style.display = '';
  77. document.getElementById('div3').style.display = 'none';
  78. document.getElementById('div4').style.display = 'none';
  79. document.uniform.subject3.selectedIndex = 0;
  80. document.uniform.subject4.selectedIndex = 0;
  81. }
  82. else if(document.uniform.level.value == "3")
  83. {
  84. document.getElementById('div1').style.display = '';
  85. document.getElementById('div2').style.display = '';
  86. document.getElementById('div3').style.display = '';
  87. document.getElementById('div4').style.display = 'none';
  88. document.uniform.subject4.selectedIndex = 0;
  89. }
  90. else if(document.uniform.level.value == "4")
  91. {
  92. document.getElementById('div1').style.display = '';
  93. document.getElementById('div2').style.display = '';
  94. document.getElementById('div3').style.display = '';
  95. document.getElementById('div4').style.display = '';
  96. }
  97.  
  98. document.getElementById('divTimetable').style.display = 'none';
  99. document.uniform.subject1.selectedIndex = 0;
  100. document.uniform.subject2.selectedIndex = 0;
  101. document.uniform.subject3.selectedIndex = 0;
  102. document.uniform.subject4.selectedIndex = 0;
  103.  
  104. SubjectNames();
  105.  
  106. update();
  107. }
  108.  
  109. function update() // changes made: reversed style and option disable
  110. {
  111. for(var i=1; i<document.uniform.subject1.options.length; i++)
  112. {
  113. if (document.uniform.subject1.value < 1)
  114. {
  115. document.uniform.subject1.options[i].disabled = false;
  116. document.uniform.subject1.options[i].style.display = '';
  117. }
  118. if (document.uniform.subject2.value < 1)
  119. {
  120. document.uniform.subject2.options[i].disabled = false;
  121. document.uniform.subject2.options[i].style.display = '';
  122. }
  123. if (document.uniform.subject3.value < 1)
  124. {
  125. document.uniform.subject3.options[i].disabled = false;
  126. document.uniform.subject3.options[i].style.display = '';
  127. }
  128. if (document.uniform.subject4.value < 1)
  129. {
  130. document.uniform.subject4.options[i].disabled = false;
  131. document.uniform.subject4.options[i].style.display = '';
  132. }
  133. }
  134.  
  135. }
  136.  
  137.  
  138. function displayTimetable()
  139. {
  140.  
  141. var xmlhttp;
  142. if(window.XMLHttpRequest)
  143. {
  144. xmlhttp=new XMLHttpRequest();
  145. }
  146. else
  147. {
  148. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  149. }
  150.  
  151. si1 = document.uniform.subject1.selectedIndex;
  152. si2 = document.uniform.subject2.selectedIndex;
  153. si3 = document.uniform.subject3.selectedIndex;
  154. si4 = document.uniform.subject4.selectedIndex;
  155.  
  156. var typeid = document.uniform.level.value;
  157. var subid1 = document.uniform.subject1.options[si1].value;
  158. var subid2 = document.uniform.subject2.options[si2].value;
  159. var subid3 = document.uniform.subject3.options[si3].value;
  160. var subid4 = document.uniform.subject4.options[si4].value;
  161.  
  162. xmlhttp.onreadystatechange=function()
  163. {
  164. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  165. {
  166. var response1 = xmlhttp.responseText;
  167. var response = response1.replace(/\+/g, " ");
  168. document.getElementById('divTimetable').innerHTML = unescape(response);
  169. document.getElementById('divTimetable').style.display = '';
  170. }
  171. }
  172.  
  173. xmlhttp.open("GET", "./timetable.php?typeid=" + typeid + "&subid1="+subid1 + "&subid2="+subid2 + "&subid3="+subid3 + "&subid4="+subid4, true);
  174. xmlhttp.send();
  175. }
  176.  
  177. function SubjectNames()
  178. {
  179. if(document.uniform.level.value == "1")
  180. {
  181. document.getElementById('sub1').innerHTML = "Fach 1: ";
  182. document.getElementById('sub2').innerHTML = "Fach 2: ";
  183. document.getElementById('sub3').innerHTML = "Individual-Profil: ";
  184. }
  185. if(document.uniform.level.value == "2")
  186. {
  187. document.getElementById('sub1').innerHTML = "Fach 1: ";
  188. document.getElementById('sub2').innerHTML = "Fach 2: ";
  189. }
  190. if(document.uniform.level.value == "3")
  191. {
  192. document.getElementById('sub1').innerHTML = "Fach 1: ";
  193. document.getElementById('sub2').innerHTML = "Fach 2: ";
  194. document.getElementById('sub3').innerHTML = "Individual-Profil: ";
  195. }
  196. if(document.uniform.level.value == "4")
  197. {
  198. document.getElementById('sub1').innerHTML = "Fach: ";
  199. document.getElementById('sub2').innerHTML = "Vertiefungsfach: ";
  200. document.getElementById('sub3').innerHTML = "Vertiefungsfach: ";
  201. document.getElementById('sub4').innerHTML = "Individual-Profil: ";
  202. }
  203. }
  204.  
  205.  
  206. function DisableSubs()
  207. {
  208.  
  209.  
  210. var xmlhttp;
  211. if(window.XMLHttpRequest)
  212. {
  213. xmlhttp=new XMLHttpRequest();
  214. }
  215. else
  216. {
  217. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  218. }
  219.  
  220.  
  221. si1 = document.uniform.subject1.selectedIndex;
  222. si2 = document.uniform.subject2.selectedIndex;
  223. si3 = document.uniform.subject3.selectedIndex;
  224. si4 = document.uniform.subject4.selectedIndex;
  225.  
  226. var typeid = document.uniform.level.value;
  227. var subid1 = document.uniform.subject1.options[si1].value;
  228. var subid2 = document.uniform.subject2.options[si2].value;
  229. var subid3 = document.uniform.subject3.options[si3].value;
  230. var subid4 = document.uniform.subject4.options[si4].value;
  231.  
  232.  
  233. xmlhttp.onreadystatechange=function()
  234. {
  235. //alert('GYPSY');
  236. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  237. {
  238. var response = xmlhttp.responseText;
  239. eval(response.replace(/\n/g, " "));
  240. }
  241. }
  242.  
  243. xmlhttp.open("GET", "./disablesubs.php?typeid="+typeid + "&subid1="+subid1 + "&subid2="+subid2 + "&subid3="+subid3 + "&subid4="+subid4 + "&si1="+si1 + "&si2="+si2 + "&si3="+si3 + "&si4="+si4, true);
  244. xmlhttp.send();
  245.  
  246. }
  247. function sleep(milliSeconds){
  248. var startTime = new Date().getTime(); // get the current time
  249. while (new Date().getTime() < startTime + milliSeconds); // hog cpu
  250. }
  251.  
  252. function disableSelected() {
  253. document.uniform.subject2.options[si1].disabled = true;
  254. document.uniform.subject2.options[si3].disabled = true;
  255. document.uniform.subject2.options[si4].disabled = true;
  256. document.uniform.subject3.options[si1].disabled = true;
  257. document.uniform.subject3.options[si2].disabled = true;
  258. document.uniform.subject3.options[si4].disabled = true;
  259. document.uniform.subject4.options[si1].disabled = true;
  260. document.uniform.subject4.options[si2].disabled = true;
  261. document.uniform.subject4.options[si3].disabled = true;
  262.  
  263. for(var i=1; i<document.uniform.subject1.options.length; i++)
  264. {
  265. document.uniform.subject1.options[i].disabled = false;
  266. document.uniform.subject1.options[i].style.display = '';
  267. }
  268. }
  269.  
  270.  
  271. </script>
  272.  
  273.  
  274. <table>
  275. <tr>
  276.  
  277. <form name="uniform">
  278. <td><span style="">Profil:</span>
  279. <select style="width: 200px;" name="level" value="1" onchange="typeChanged();">
  280. <option value="">- Auswählen -</option>
  281. <?php
  282. $pages_table_name = "uni_types";
  283.  
  284. $con = mysql_connect($sv_name, $username, $password) or die(mysql_error());
  285. mysql_select_db($db_name, $con) or die(mysql_error());
  286.  
  287. $query = "SELECT * FROM " . $pages_table_name;
  288. $result_types = mysql_query($query, $con) or die(mysql_error());
  289. while($row_types = mysql_fetch_array($result_types))
  290. {
  291. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  292. }
  293. ?>
  294. </select></td>
  295. <td><a href="" onclick="ClearChoices(); return false;">Zurücksetzen</a></td>
  296. </tr>
  297. <tr>
  298. <td><div id="div1" style="display:none;">
  299. <div id="sub1" style="float: left;"></div>
  300. <select name="subject1" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject2.selectedIndex = 0; document.uniform.subject3.selectedIndex = 0; document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable(); disableSelected() ">
  301. <option value="0" >- Auswählen -</option>
  302.  
  303. <?php
  304. $pages_table_name = "uni_subjects";
  305.  
  306. $query = "SELECT * FROM " . $pages_table_name;
  307. $result_types = mysql_query($query, $con) or die(mysql_error());
  308. $subcount = 0;
  309. while($row_types = mysql_fetch_array($result_types))
  310. {
  311. if ($row_types['name'] != "DELETED")
  312. {
  313. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  314. $subcount++;
  315. }
  316. }
  317. ?>
  318. </select>
  319. </div></td>
  320.  
  321. <td><div id="div2" style="display:none;">
  322. <div id="sub2" style="float: left;"></div>
  323. <select name="subject2" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject3.selectedIndex = 0; document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable(); disableSelected()">
  324. <option value="0" >- Auswählen -</option>
  325.  
  326. <?php
  327. $pages_table_name = "uni_subjects";
  328.  
  329. $query = "SELECT * FROM " . $pages_table_name;
  330. $result_types = mysql_query($query, $con) or die(mysql_error());
  331. while($row_types = mysql_fetch_array($result_types))
  332. {
  333. if ($row_types['name'] != "DELETED")
  334. {
  335. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  336. }
  337. }
  338. ?>
  339. </select>
  340. </div></td>
  341.  
  342. <td><div id="div3" style="display:none;">
  343. <div id="sub3" style="float: left;"></div>
  344. <select name="subject3" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable(); disableSelected()">
  345. <option value="0" >- Auswählen -</option>
  346.  
  347. <?php
  348. $pages_table_name = "uni_subjects";
  349.  
  350. $query = "SELECT * FROM " . $pages_table_name;
  351. $result_types = mysql_query($query, $con) or die(mysql_error());
  352. while($row_types = mysql_fetch_array($result_types))
  353. {
  354. if ($row_types['name'] != "DELETED")
  355. {
  356. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  357. }
  358. }
  359. ?>
  360. </select>
  361. </div></td>
  362.  
  363. <td><div id="div4" style="display:none;">
  364. <div id="sub4" style="float: left;"></div>
  365. <select name="subject4" style="margin-right: 20px; width: 150px;" onchange="update(); DisableSubs(); displayTimetable(); disableSelected()">
  366. <option value="0" >- Auswählen -</option>
  367.  
  368. <?php
  369. $pages_table_name = "uni_subjects";
  370.  
  371. $query = "SELECT * FROM " . $pages_table_name;
  372. $result_types = mysql_query($query, $con) or die(mysql_error());
  373. while($row_types = mysql_fetch_array($result_types))
  374. {
  375. if ($row_types['name'] != "DELETED")
  376. {
  377. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  378. }
  379. }
  380. ?>
  381. </select>
  382. </div></td>
  383.  
  384.  
  385.  
  386.  
  387.  
  388. <script id="disablesubs" type="text/javascript">
  389.  
  390. </script>
  391.  
  392.  
  393. <input type="hidden" name="combinationid" />
  394. <br />
  395. <input name="showTimetable" type="hidden" value="Show Timetable" />
  396.  
  397. </form>
  398.  
  399. </tr>
  400. </table>
  401.  
  402.  
  403. <script type="text/javascript">
  404. document.uniform.subject1.selectedIndex = 0;
  405. document.uniform.subject2.selectedIndex = 0;
  406. document.uniform.subject3.selectedIndex = 0;
  407. document.uniform.subject4.selectedIndex = 0;
  408.  
  409. document.getElementById('div4').style.display = 'none';
  410. </script>
  411.  
  412.  
  413.  
  414.  
  415. <div id="divTimetable" style="margin-left: 10px; margin-top: 100px; width: 98%;">
  416. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement