Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.06 KB | None | 0 0
  1. <?php
  2. $sv_name = "";
  3. $username = "";
  4. $password = "";
  5. $db_name = "";
  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.  
  34. loaded();
  35.  
  36. function loaded()
  37. {
  38. if(window.XMLHttpRequest)
  39. {
  40. xmlhttp=new XMLHttpRequest();
  41. }
  42. else
  43. {
  44. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  45. }
  46. }
  47.  
  48. function ClearChoices()
  49. {
  50. document.getElementById('div1').style.display = 'none';
  51. document.getElementById('div2').style.display = 'none';
  52. document.getElementById('div3').style.display = 'none';
  53. document.getElementById('div4').style.display = 'none';
  54. document.getElementById('divTimetable').style.display = 'none';
  55. document.uniform.level.selectedIndex = 0;
  56. document.uniform.subject1.selectedIndex = 0;
  57. document.uniform.subject2.selectedIndex = 0;
  58. document.uniform.subject3.selectedIndex = 0;
  59. document.uniform.subject4.selectedIndex = 0;
  60. }
  61.  
  62. function typeChanged()
  63. {
  64. if(document.uniform.level.value == "1")
  65. {
  66. document.getElementById('div1').style.display = '';
  67. document.getElementById('div2').style.display = '';
  68. document.getElementById('div3').style.display = '';
  69. document.getElementById('div4').style.display = 'none';
  70. document.uniform.subject4.selectedIndex = 0;
  71. }
  72. else if(document.uniform.level.value == "2")
  73. {
  74. document.getElementById('div1').style.display = '';
  75. document.getElementById('div2').style.display = '';
  76. document.getElementById('div3').style.display = 'none';
  77. document.getElementById('div4').style.display = 'none';
  78. document.uniform.subject3.selectedIndex = 0;
  79. document.uniform.subject4.selectedIndex = 0;
  80. }
  81. else if(document.uniform.level.value == "3")
  82. {
  83. document.getElementById('div1').style.display = '';
  84. document.getElementById('div2').style.display = '';
  85. document.getElementById('div3').style.display = '';
  86. document.getElementById('div4').style.display = 'none';
  87. document.uniform.subject4.selectedIndex = 0;
  88. }
  89. else if(document.uniform.level.value == "4")
  90. {
  91. document.getElementById('div1').style.display = '';
  92. document.getElementById('div2').style.display = '';
  93. document.getElementById('div3').style.display = '';
  94. document.getElementById('div4').style.display = '';
  95. }
  96.  
  97. document.getElementById('divTimetable').style.display = 'none';
  98. document.uniform.subject1.selectedIndex = 0;
  99. document.uniform.subject2.selectedIndex = 0;
  100. document.uniform.subject3.selectedIndex = 0;
  101. document.uniform.subject4.selectedIndex = 0;
  102.  
  103. SubjectNames();
  104.  
  105. update();
  106. }
  107.  
  108. function update() // changes made: reversed style and option disable
  109. {
  110. for(var i=1; i<document.uniform.subject1.options.length; i++)
  111. {
  112. if (document.uniform.subject1.value < 1)
  113. {
  114. document.uniform.subject1.options[i].disabled = false;
  115. document.uniform.subject1.options[i].style.display = '';
  116. }
  117. if (document.uniform.subject2.value < 1)
  118. {
  119. document.uniform.subject2.options[i].disabled = false;
  120. document.uniform.subject2.options[i].style.display = '';
  121. }
  122. if (document.uniform.subject3.value < 1)
  123. {
  124. document.uniform.subject3.options[i].disabled = false;
  125. document.uniform.subject3.options[i].style.display = '';
  126. }
  127. if (document.uniform.subject4.value < 1)
  128. {
  129. document.uniform.subject4.options[i].disabled = false;
  130. document.uniform.subject4.options[i].style.display = '';
  131. }
  132. }
  133. }
  134.  
  135.  
  136. function displayTimetable()
  137. {
  138. loaded();
  139.  
  140. xmlhttp.onreadystatechange=function()
  141. {
  142. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  143. {
  144. var response1 = xmlhttp.responseText;
  145. var response = response1.replace(/\+/g, " ");
  146. document.getElementById('divTimetable').innerHTML = unescape(response);
  147. document.getElementById('divTimetable').style.display = '';
  148. }
  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.open("GET", "./timetable.php?typeid=" + typeid + "&subid1="+subid1 + "&subid2="+subid2 + "&subid3="+subid3 + "&subid4="+subid4, true);
  163. xmlhttp.send();
  164. }
  165.  
  166. function SubjectNames()
  167. {
  168. if(document.uniform.level.value == "1")
  169. {
  170. document.getElementById('sub1').innerHTML = "Fach 1: ";
  171. document.getElementById('sub2').innerHTML = "Fach 2: ";
  172. document.getElementById('sub3').innerHTML = "Individual-Profil: ";
  173. }
  174. if(document.uniform.level.value == "2")
  175. {
  176. document.getElementById('sub1').innerHTML = "Fach 1: ";
  177. document.getElementById('sub2').innerHTML = "Fach 2: ";
  178. }
  179. if(document.uniform.level.value == "3")
  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 == "4")
  186. {
  187. document.getElementById('sub1').innerHTML = "Fach: ";
  188. document.getElementById('sub2').innerHTML = "Vertiefungsfach: ";
  189. document.getElementById('sub3').innerHTML = "Vertiefungsfach: ";
  190. document.getElementById('sub4').innerHTML = "Individual-Profil: ";
  191. }
  192. }
  193.  
  194. </script>
  195.  
  196.  
  197. <table>
  198. <tr>
  199.  
  200. <form name="uniform">
  201. <td><span style="">Profil:</span>
  202. <select style="width: 200px;" name="level" value="1" onchange="typeChanged(); DisableSubs();">
  203. <option value="">- Auswählen -</option>
  204. <?php
  205. $pages_table_name = "uni_types";
  206.  
  207. $con = mysql_connect($sv_name, $username, $password) or die(mysql_error());
  208. mysql_select_db($db_name, $con) or die(mysql_error());
  209.  
  210. $query = "SELECT * FROM " . $pages_table_name;
  211. $result_types = mysql_query($query, $con) or die(mysql_error());
  212. while($row_types = mysql_fetch_array($result_types))
  213. {
  214. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  215. }
  216. ?>
  217. </select></td>
  218. <td><a href="" onclick="ClearChoices(); return false;">Zurücksetzen</a></td>
  219. </tr>
  220. <tr>
  221. <td><div id="div1" style="display:none;">
  222. <div id="sub1" style="float: left;"></div>
  223. <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(); ">
  224. <option value="0" >- Auswählen -</option>
  225.  
  226. <?php
  227. $pages_table_name = "uni_subjects";
  228.  
  229. $query = "SELECT * FROM " . $pages_table_name;
  230. $result_types = mysql_query($query, $con) or die(mysql_error());
  231. while($row_types = mysql_fetch_array($result_types))
  232. {
  233. if ($row_types['name'] != "DELETED")
  234. {
  235. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  236. }
  237. }
  238. ?>
  239. </select>
  240. </div></td>
  241.  
  242. <td><div id="div2" style="display:none;">
  243. <div id="sub2" style="float: left;"></div>
  244. <select name="subject2" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject3.selectedIndex = 0; document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable();">
  245. <option value="0" >- Auswählen -</option>
  246.  
  247. <?php
  248. $pages_table_name = "uni_subjects";
  249.  
  250. $query = "SELECT * FROM " . $pages_table_name;
  251. $result_types = mysql_query($query, $con) or die(mysql_error());
  252. while($row_types = mysql_fetch_array($result_types))
  253. {
  254. if ($row_types['name'] != "DELETED")
  255. {
  256. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  257. }
  258. }
  259. ?>
  260. </select>
  261. </div></td>
  262.  
  263. <td><div id="div3" style="display:none;">
  264. <div id="sub3" style="float: left;"></div>
  265. <select name="subject3" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable();">
  266. <option value="0" >- Auswählen -</option>
  267.  
  268. <?php
  269. $pages_table_name = "uni_subjects";
  270.  
  271. $query = "SELECT * FROM " . $pages_table_name;
  272. $result_types = mysql_query($query, $con) or die(mysql_error());
  273. while($row_types = mysql_fetch_array($result_types))
  274. {
  275. if ($row_types['name'] != "DELETED")
  276. {
  277. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  278. }
  279. }
  280. ?>
  281. </select>
  282. </div></td>
  283.  
  284. <td><div id="div4" style="display:none;">
  285. <div id="sub4" style="float: left;"></div>
  286. <select name="subject4" style="margin-right: 20px; width: 150px;" onchange="update(); DisableSubs(); displayTimetable();">
  287. <option value="0" >- Auswählen -</option>
  288.  
  289. <?php
  290. $pages_table_name = "uni_subjects";
  291.  
  292. $query = "SELECT * FROM " . $pages_table_name;
  293. $result_types = mysql_query($query, $con) or die(mysql_error());
  294. while($row_types = mysql_fetch_array($result_types))
  295. {
  296. if ($row_types['name'] != "DELETED")
  297. {
  298. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  299. }
  300. }
  301. ?>
  302. </select>
  303. </div></td>
  304.  
  305.  
  306. <?php
  307. echo "<script type=\"text/javascript\">
  308. function DisableSubs()
  309. {
  310. lvl = document.uniform.level.value;
  311.  
  312. si1 = document.uniform.subject1.selectedIndex;
  313. si2 = document.uniform.subject2.selectedIndex;
  314. si3 = document.uniform.subject3.selectedIndex;
  315. si4 = document.uniform.subject4.selectedIndex;
  316.  
  317.  
  318.  
  319.  
  320. ";
  321. $pages_table_name = "uni_combinations";
  322. $query_subjects = "SELECT * FROM " . $pages_table_name;
  323. $result_subjects = mysql_query($query_subjects, $con) or die(mysql_error());
  324.  
  325.  
  326. while($row_subjects = mysql_fetch_array($result_subjects))
  327. {
  328. echo "
  329.  
  330. if (
  331. lvl == " . $row_subjects['typeid'] . " &&
  332. (
  333.  
  334. (document.uniform.subject1.options[si1].value == " . $row_subjects['subid1'] . " ||
  335. document.uniform.subject1.options[si1].value == 0)
  336. &&
  337. (document.uniform.subject2.options[si2].value == " . $row_subjects['subid2'] . " ||
  338. document.uniform.subject2.options[si2].value == 0)
  339. &&
  340. (document.uniform.subject3.options[si3].value == " . $row_subjects['subid3'] . " ||
  341. document.uniform.subject3.options[si3].value == 0)
  342. &&
  343. (document.uniform.subject4.options[si4].value == " . $row_subjects['subid4'] . " ||
  344. document.uniform.subject4.options[si4].value == 0)
  345.  
  346. )
  347. )
  348. {
  349.  
  350. for (var y=1; y<document.uniform.subject1.options.length; y++)
  351. {
  352. isvalid1 = 1;
  353. isvalid2 = 1;
  354. isvalid3 = 1;
  355. isvalid4 = 1;
  356. if(document.uniform.subject1.options[y].value == " . $row_subjects['subid1'] . ")
  357. {
  358. sub1 = y;
  359. }
  360. else
  361. {
  362. isvalid1 = 0;
  363. }
  364. if(document.uniform.subject1.options[y].value == " . $row_subjects['subid2'] . ")
  365. {
  366. sub2 = y;
  367. }
  368. else
  369. {
  370. isvalid2 = 0;
  371. }
  372. if(document.uniform.subject1.options[y].value == " . $row_subjects['subid3'] . ")
  373. {
  374. sub3 = y;
  375. }
  376. else
  377. {
  378. isvalid3 = 0;
  379. }
  380. if(document.uniform.subject1.options[y].value == " . $row_subjects['subid4'] . ")
  381. {
  382. sub4 = y;
  383. }
  384. else
  385. {
  386. isvalid4 = 0;
  387. }
  388. // changes made: reversed style and option disable
  389. if (isvalid1 == 1 &&
  390. " . $row_subjects['subid1'] . " != document.uniform.subject1.options[si1].value &&
  391. " . $row_subjects['subid1'] . " != document.uniform.subject2.options[si2].value &&
  392. " . $row_subjects['subid1'] . " != document.uniform.subject3.options[si3].value &&
  393. " . $row_subjects['subid1'] . " != document.uniform.subject4.options[si4].value)
  394. {
  395. document.uniform.subject1.options[sub1].disabled = true;
  396.  
  397. document.uniform.subject1.options[sub1].style.display = 'none';
  398. }
  399. if (isvalid2 == 1 &&
  400. " . $row_subjects['subid2'] . " != document.uniform.subject1.options[si1].value &&
  401. " . $row_subjects['subid2'] . " != document.uniform.subject2.options[si2].value &&
  402. " . $row_subjects['subid2'] . " != document.uniform.subject3.options[si3].value &&
  403. " . $row_subjects['subid2'] . " != document.uniform.subject4.options[si4].value)
  404. {
  405. document.uniform.subject2.options[sub2].disabled = true;
  406.  
  407. document.uniform.subject2.options[sub2].style.display = 'none';
  408. }
  409. if (isvalid3 == 1 &&
  410. " . $row_subjects['subid3'] . " != document.uniform.subject1.options[si1].value &&
  411. " . $row_subjects['subid3'] . " != document.uniform.subject2.options[si2].value &&
  412. " . $row_subjects['subid3'] . " != document.uniform.subject3.options[si3].value &&
  413. " . $row_subjects['subid3'] . " != document.uniform.subject4.options[si4].value)
  414. {
  415. document.uniform.subject3.options[sub3].disabled = true;
  416.  
  417. document.uniform.subject3.options[sub3].style.display = 'none';
  418. }
  419. if (isvalid4 == 1 &&
  420. " . $row_subjects['subid4'] . " != document.uniform.subject1.options[si1].value &&
  421. " . $row_subjects['subid4'] . " != document.uniform.subject2.options[si2].value &&
  422. " . $row_subjects['subid4'] . " != document.uniform.subject3.options[si3].value &&
  423. " . $row_subjects['subid4'] . " != document.uniform.subject4.options[si4].value)
  424. {
  425. document.uniform.subject4.options[sub4].disabled = true;
  426.  
  427. document.uniform.subject4.options[sub4].style.display = 'none';
  428. }
  429.  
  430.  
  431. }
  432. }
  433.  
  434. ";
  435.  
  436.  
  437. }
  438.  
  439.  
  440.  
  441. echo "
  442. document.uniform.subject1.options[si2].disabled = true;
  443. document.uniform.subject1.options[si3].disabled = true;
  444. document.uniform.subject1.options[si4].disabled = true;
  445. document.uniform.subject2.options[si1].disabled = true;
  446. document.uniform.subject2.options[si3].disabled = true;
  447. document.uniform.subject2.options[si4].disabled = true;
  448. document.uniform.subject3.options[si1].disabled = true;
  449. document.uniform.subject3.options[si2].disabled = true;
  450. document.uniform.subject3.options[si4].disabled = true;
  451. document.uniform.subject4.options[si1].disabled = true;
  452. document.uniform.subject4.options[si2].disabled = true;
  453. document.uniform.subject4.options[si3].disabled = true;
  454.  
  455. for(var i=1; i<document.uniform.subject1.options.length; i++)
  456. {
  457. document.uniform.subject1.options[i].disabled = false;
  458. document.uniform.subject1.options[i].style.display = '';
  459. }
  460.  
  461. }
  462.  
  463.  
  464.  
  465. </script>";
  466. ?>
  467.  
  468. <input type="hidden" name="combinationid" />
  469. <br />
  470. <input name="showTimetable" type="hidden" value="Show Timetable" />
  471.  
  472. </form>
  473.  
  474. </tr>
  475. </table>
  476.  
  477.  
  478. <script type="text/javascript">
  479. document.uniform.subject1.selectedIndex = 0;
  480. document.uniform.subject2.selectedIndex = 0;
  481. document.uniform.subject3.selectedIndex = 0;
  482. document.uniform.subject4.selectedIndex = 0;
  483.  
  484. document.getElementById('div4').style.display = 'none';
  485. </script>
  486.  
  487.  
  488.  
  489.  
  490. <div id="divTimetable" style="margin-left: 10px; margin-top: 100px; width: 98%;">
  491. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement