Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.32 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. 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('div1type1').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('div1type1').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('div1type1').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('div1type1').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('div1type1').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. function openImg(filename) {
  272. document.getElementById('popupimg').style.display = '';
  273. document.getElementById('popupimg').innerHTML = "<img src=\"close.png\" style=\"margin-left: 770px; margin-top: 5px; position: absolute;\" onclick=\"closeImg()\" onmouseover=\"this.style.cursor='pointer';\" /><img src='"+filename+"' onclick=\"closeImg()\" onmouseover=\"this.style.cursor='pointer';\" />";
  274. }
  275.  
  276. function closeImg() {
  277. document.getElementById('popupimg').style.display = 'none';
  278. document.getElementById('popupimg').innerHTML = "";
  279. }
  280.  
  281.  
  282. </script>
  283.  
  284. <div id="popupimg" style="display: none; position: absolute; margin-left: 200px; padding: 5px;box-shadow:inset 0 0 10px #000000; background-color: #ffffff;"></div>
  285.  
  286. <table>
  287. <tr>
  288.  
  289. <form name="uniform">
  290. <td><span style="">Profil:</span>
  291. <select style="width: 200px;" name="level" value="1" onchange="typeChanged();">
  292. <option value="">- Auswählen -</option>
  293. <?php
  294. $pages_table_name = "uni_types";
  295.  
  296. $con = mysql_connect($sv_name, $username, $password) or die(mysql_error());
  297. mysql_select_db($db_name, $con) or die(mysql_error());
  298.  
  299. $query = "SELECT * FROM " . $pages_table_name;
  300. $result_types = mysql_query($query, $con) or die(mysql_error());
  301. while($row_types = mysql_fetch_array($result_types))
  302. {
  303. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  304. }
  305. ?>
  306. </select></td>
  307. <td><a href="" onclick="ClearChoices(); return false;">Zurücksetzen</a></td>
  308. </tr>
  309. <tr>
  310. <td>
  311. <div id="div1type1" style="display:none;">
  312. <div id="sub1" style="float: left;"></div>
  313. <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() ">
  314. <option value="0" >- Auswählen -</option>
  315. <?php
  316. $pages_table_name = "uni_subjects";
  317. $query = "SELECT * FROM " . $pages_table_name;
  318. $result_types = mysql_query($query, $con) or die(mysql_error());
  319. $subcount = 0;
  320. while($row_types = mysql_fetch_array($result_types))
  321. {
  322. if ($row_types['name'] != "DELETED")
  323. {
  324. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  325. $subcount++;
  326. }
  327. }
  328. ?>
  329. </select>
  330. </div>
  331.  
  332. </td>
  333.  
  334. <td><div id="div2" style="display:none;">
  335. <div id="sub2" style="float: left;"></div>
  336. <select name="subject2" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject3.selectedIndex = 0; document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable(); disableSelected()">
  337. <option value="0" >- Auswählen -</option>
  338.  
  339. <?php
  340. $pages_table_name = "uni_subjects";
  341.  
  342. $query = "SELECT * FROM " . $pages_table_name;
  343. $result_types = mysql_query($query, $con) or die(mysql_error());
  344. while($row_types = mysql_fetch_array($result_types))
  345. {
  346. if ($row_types['name'] != "DELETED")
  347. {
  348. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  349. }
  350. }
  351. ?>
  352. </select>
  353. </div></td>
  354.  
  355. <td><div id="div3" style="display:none;">
  356. <div id="sub3" style="float: left;"></div>
  357. <select name="subject3" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable(); disableSelected()">
  358. <option value="0" >- Auswählen -</option>
  359.  
  360. <?php
  361. $pages_table_name = "uni_subjects";
  362.  
  363. $query = "SELECT * FROM " . $pages_table_name;
  364. $result_types = mysql_query($query, $con) or die(mysql_error());
  365. while($row_types = mysql_fetch_array($result_types))
  366. {
  367. if ($row_types['name'] != "DELETED")
  368. {
  369. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  370. }
  371. }
  372. ?>
  373. </select>
  374. </div></td>
  375.  
  376. <td><div id="div4" style="display:none;">
  377. <div id="sub4" style="float: left;"></div>
  378. <select name="subject4" style="margin-right: 20px; width: 150px;" onchange="update(); DisableSubs(); displayTimetable(); disableSelected()">
  379. <option value="0" >- Auswählen -</option>
  380.  
  381. <?php
  382. $pages_table_name = "uni_subjects";
  383.  
  384. $query = "SELECT * FROM " . $pages_table_name;
  385. $result_types = mysql_query($query, $con) or die(mysql_error());
  386. while($row_types = mysql_fetch_array($result_types))
  387. {
  388. if ($row_types['name'] != "DELETED")
  389. {
  390. echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
  391. }
  392. }
  393. ?>
  394. </select>
  395. </div></td>
  396.  
  397.  
  398.  
  399.  
  400.  
  401. <script id="disablesubs" type="text/javascript">
  402.  
  403. </script>
  404.  
  405.  
  406. <input type="hidden" name="combinationid" />
  407. <br />
  408. <input name="showTimetable" type="hidden" value="Show Timetable" />
  409.  
  410. </form>
  411.  
  412. </tr>
  413. </table>
  414.  
  415.  
  416. <script type="text/javascript">
  417. document.uniform.subject1.selectedIndex = 0;
  418. document.uniform.subject2.selectedIndex = 0;
  419. document.uniform.subject3.selectedIndex = 0;
  420. document.uniform.subject4.selectedIndex = 0;
  421.  
  422. document.getElementById('div4').style.display = 'none';
  423. </script>
  424.  
  425.  
  426.  
  427.  
  428. <div id="divTimetable" style="margin-left: 10px; margin-top: 100px; width: 98%;">
  429. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement