Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $sv_name = "";
- $username = "";
- $password = "";
- $db_name = "";
- ?>
- <script type="text/javascript">
- var psi1;
- var psi2;
- var psi3;
- var psi4;
- var xmlhttp;
- var lvl;
- var sub1;
- var sub2;
- var sub3;
- var sub4;
- var si1;
- var si2;
- var si3;
- var si4;
- var todisable;
- var isvalid1;
- var isvalid2;
- var isvalid3;
- var isvalid4;
- loaded();
- function loaded()
- {
- if(window.XMLHttpRequest)
- {
- xmlhttp=new XMLHttpRequest();
- }
- else
- {
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- }
- function ClearChoices()
- {
- document.getElementById('div1').style.display = 'none';
- document.getElementById('div2').style.display = 'none';
- document.getElementById('div3').style.display = 'none';
- document.getElementById('div4').style.display = 'none';
- document.getElementById('divTimetable').style.display = 'none';
- document.uniform.level.selectedIndex = 0;
- document.uniform.subject1.selectedIndex = 0;
- document.uniform.subject2.selectedIndex = 0;
- document.uniform.subject3.selectedIndex = 0;
- document.uniform.subject4.selectedIndex = 0;
- }
- function typeChanged()
- {
- if(document.uniform.level.value == "1")
- {
- document.getElementById('div1').style.display = '';
- document.getElementById('div2').style.display = '';
- document.getElementById('div3').style.display = '';
- document.getElementById('div4').style.display = 'none';
- document.uniform.subject4.selectedIndex = 0;
- }
- else if(document.uniform.level.value == "2")
- {
- document.getElementById('div1').style.display = '';
- document.getElementById('div2').style.display = '';
- document.getElementById('div3').style.display = 'none';
- document.getElementById('div4').style.display = 'none';
- document.uniform.subject3.selectedIndex = 0;
- document.uniform.subject4.selectedIndex = 0;
- }
- else if(document.uniform.level.value == "3")
- {
- document.getElementById('div1').style.display = '';
- document.getElementById('div2').style.display = '';
- document.getElementById('div3').style.display = '';
- document.getElementById('div4').style.display = 'none';
- document.uniform.subject4.selectedIndex = 0;
- }
- else if(document.uniform.level.value == "4")
- {
- document.getElementById('div1').style.display = '';
- document.getElementById('div2').style.display = '';
- document.getElementById('div3').style.display = '';
- document.getElementById('div4').style.display = '';
- }
- document.getElementById('divTimetable').style.display = 'none';
- document.uniform.subject1.selectedIndex = 0;
- document.uniform.subject2.selectedIndex = 0;
- document.uniform.subject3.selectedIndex = 0;
- document.uniform.subject4.selectedIndex = 0;
- SubjectNames();
- update();
- }
- function update() // changes made: reversed style and option disable
- {
- for(var i=1; i<document.uniform.subject1.options.length; i++)
- {
- if (document.uniform.subject1.value < 1)
- {
- document.uniform.subject1.options[i].disabled = false;
- document.uniform.subject1.options[i].style.display = '';
- }
- if (document.uniform.subject2.value < 1)
- {
- document.uniform.subject2.options[i].disabled = false;
- document.uniform.subject2.options[i].style.display = '';
- }
- if (document.uniform.subject3.value < 1)
- {
- document.uniform.subject3.options[i].disabled = false;
- document.uniform.subject3.options[i].style.display = '';
- }
- if (document.uniform.subject4.value < 1)
- {
- document.uniform.subject4.options[i].disabled = false;
- document.uniform.subject4.options[i].style.display = '';
- }
- }
- }
- function displayTimetable()
- {
- loaded();
- xmlhttp.onreadystatechange=function()
- {
- if (xmlhttp.readyState==4 && xmlhttp.status==200)
- {
- var response1 = xmlhttp.responseText;
- var response = response1.replace(/\+/g, " ");
- document.getElementById('divTimetable').innerHTML = unescape(response);
- document.getElementById('divTimetable').style.display = '';
- }
- }
- si1 = document.uniform.subject1.selectedIndex;
- si2 = document.uniform.subject2.selectedIndex;
- si3 = document.uniform.subject3.selectedIndex;
- si4 = document.uniform.subject4.selectedIndex;
- var typeid = document.uniform.level.value;
- var subid1 = document.uniform.subject1.options[si1].value;
- var subid2 = document.uniform.subject2.options[si2].value;
- var subid3 = document.uniform.subject3.options[si3].value;
- var subid4 = document.uniform.subject4.options[si4].value;
- xmlhttp.open("GET", "./timetable.php?typeid=" + typeid + "&subid1="+subid1 + "&subid2="+subid2 + "&subid3="+subid3 + "&subid4="+subid4, true);
- xmlhttp.send();
- }
- function SubjectNames()
- {
- if(document.uniform.level.value == "1")
- {
- document.getElementById('sub1').innerHTML = "Fach 1: ";
- document.getElementById('sub2').innerHTML = "Fach 2: ";
- document.getElementById('sub3').innerHTML = "Individual-Profil: ";
- }
- if(document.uniform.level.value == "2")
- {
- document.getElementById('sub1').innerHTML = "Fach 1: ";
- document.getElementById('sub2').innerHTML = "Fach 2: ";
- }
- if(document.uniform.level.value == "3")
- {
- document.getElementById('sub1').innerHTML = "Fach 1: ";
- document.getElementById('sub2').innerHTML = "Fach 2: ";
- document.getElementById('sub3').innerHTML = "Individual-Profil: ";
- }
- if(document.uniform.level.value == "4")
- {
- document.getElementById('sub1').innerHTML = "Fach: ";
- document.getElementById('sub2').innerHTML = "Vertiefungsfach: ";
- document.getElementById('sub3').innerHTML = "Vertiefungsfach: ";
- document.getElementById('sub4').innerHTML = "Individual-Profil: ";
- }
- }
- </script>
- <table>
- <tr>
- <form name="uniform">
- <td><span style="">Profil:</span>
- <select style="width: 200px;" name="level" value="1" onchange="typeChanged(); DisableSubs();">
- <option value="">- Auswählen -</option>
- <?php
- $pages_table_name = "uni_types";
- $con = mysql_connect($sv_name, $username, $password) or die(mysql_error());
- mysql_select_db($db_name, $con) or die(mysql_error());
- $query = "SELECT * FROM " . $pages_table_name;
- $result_types = mysql_query($query, $con) or die(mysql_error());
- while($row_types = mysql_fetch_array($result_types))
- {
- echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
- }
- ?>
- </select></td>
- <td><a href="" onclick="ClearChoices(); return false;">Zurücksetzen</a></td>
- </tr>
- <tr>
- <td><div id="div1" style="display:none;">
- <div id="sub1" style="float: left;"></div>
- <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(); ">
- <option value="0" >- Auswählen -</option>
- <?php
- $pages_table_name = "uni_subjects";
- $query = "SELECT * FROM " . $pages_table_name;
- $result_types = mysql_query($query, $con) or die(mysql_error());
- while($row_types = mysql_fetch_array($result_types))
- {
- if ($row_types['name'] != "DELETED")
- {
- echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
- }
- }
- ?>
- </select>
- </div></td>
- <td><div id="div2" style="display:none;">
- <div id="sub2" style="float: left;"></div>
- <select name="subject2" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject3.selectedIndex = 0; document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable();">
- <option value="0" >- Auswählen -</option>
- <?php
- $pages_table_name = "uni_subjects";
- $query = "SELECT * FROM " . $pages_table_name;
- $result_types = mysql_query($query, $con) or die(mysql_error());
- while($row_types = mysql_fetch_array($result_types))
- {
- if ($row_types['name'] != "DELETED")
- {
- echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
- }
- }
- ?>
- </select>
- </div></td>
- <td><div id="div3" style="display:none;">
- <div id="sub3" style="float: left;"></div>
- <select name="subject3" style="margin-right: 20px; width: 150px;" onchange="document.uniform.subject4.selectedIndex = 0; update(); DisableSubs(); displayTimetable();">
- <option value="0" >- Auswählen -</option>
- <?php
- $pages_table_name = "uni_subjects";
- $query = "SELECT * FROM " . $pages_table_name;
- $result_types = mysql_query($query, $con) or die(mysql_error());
- while($row_types = mysql_fetch_array($result_types))
- {
- if ($row_types['name'] != "DELETED")
- {
- echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
- }
- }
- ?>
- </select>
- </div></td>
- <td><div id="div4" style="display:none;">
- <div id="sub4" style="float: left;"></div>
- <select name="subject4" style="margin-right: 20px; width: 150px;" onchange="update(); DisableSubs(); displayTimetable();">
- <option value="0" >- Auswählen -</option>
- <?php
- $pages_table_name = "uni_subjects";
- $query = "SELECT * FROM " . $pages_table_name;
- $result_types = mysql_query($query, $con) or die(mysql_error());
- while($row_types = mysql_fetch_array($result_types))
- {
- if ($row_types['name'] != "DELETED")
- {
- echo("<option value=\"" . $row_types['id'] . "\">" . $row_types['name'] . "</option>");
- }
- }
- ?>
- </select>
- </div></td>
- <?php
- echo "<script type=\"text/javascript\">
- function DisableSubs()
- {
- lvl = document.uniform.level.value;
- si1 = document.uniform.subject1.selectedIndex;
- si2 = document.uniform.subject2.selectedIndex;
- si3 = document.uniform.subject3.selectedIndex;
- si4 = document.uniform.subject4.selectedIndex;
- ";
- $pages_table_name = "uni_combinations";
- $query_subjects = "SELECT * FROM " . $pages_table_name;
- $result_subjects = mysql_query($query_subjects, $con) or die(mysql_error());
- while($row_subjects = mysql_fetch_array($result_subjects))
- {
- echo "
- if (
- lvl == " . $row_subjects['typeid'] . " &&
- (
- (document.uniform.subject1.options[si1].value == " . $row_subjects['subid1'] . " ||
- document.uniform.subject1.options[si1].value == 0)
- &&
- (document.uniform.subject2.options[si2].value == " . $row_subjects['subid2'] . " ||
- document.uniform.subject2.options[si2].value == 0)
- &&
- (document.uniform.subject3.options[si3].value == " . $row_subjects['subid3'] . " ||
- document.uniform.subject3.options[si3].value == 0)
- &&
- (document.uniform.subject4.options[si4].value == " . $row_subjects['subid4'] . " ||
- document.uniform.subject4.options[si4].value == 0)
- )
- )
- {
- for (var y=1; y<document.uniform.subject1.options.length; y++)
- {
- isvalid1 = 1;
- isvalid2 = 1;
- isvalid3 = 1;
- isvalid4 = 1;
- if(document.uniform.subject1.options[y].value == " . $row_subjects['subid1'] . ")
- {
- sub1 = y;
- }
- else
- {
- isvalid1 = 0;
- }
- if(document.uniform.subject1.options[y].value == " . $row_subjects['subid2'] . ")
- {
- sub2 = y;
- }
- else
- {
- isvalid2 = 0;
- }
- if(document.uniform.subject1.options[y].value == " . $row_subjects['subid3'] . ")
- {
- sub3 = y;
- }
- else
- {
- isvalid3 = 0;
- }
- if(document.uniform.subject1.options[y].value == " . $row_subjects['subid4'] . ")
- {
- sub4 = y;
- }
- else
- {
- isvalid4 = 0;
- }
- // changes made: reversed style and option disable
- if (isvalid1 == 1 &&
- " . $row_subjects['subid1'] . " != document.uniform.subject1.options[si1].value &&
- " . $row_subjects['subid1'] . " != document.uniform.subject2.options[si2].value &&
- " . $row_subjects['subid1'] . " != document.uniform.subject3.options[si3].value &&
- " . $row_subjects['subid1'] . " != document.uniform.subject4.options[si4].value)
- {
- document.uniform.subject1.options[sub1].disabled = true;
- document.uniform.subject1.options[sub1].style.display = 'none';
- }
- if (isvalid2 == 1 &&
- " . $row_subjects['subid2'] . " != document.uniform.subject1.options[si1].value &&
- " . $row_subjects['subid2'] . " != document.uniform.subject2.options[si2].value &&
- " . $row_subjects['subid2'] . " != document.uniform.subject3.options[si3].value &&
- " . $row_subjects['subid2'] . " != document.uniform.subject4.options[si4].value)
- {
- document.uniform.subject2.options[sub2].disabled = true;
- document.uniform.subject2.options[sub2].style.display = 'none';
- }
- if (isvalid3 == 1 &&
- " . $row_subjects['subid3'] . " != document.uniform.subject1.options[si1].value &&
- " . $row_subjects['subid3'] . " != document.uniform.subject2.options[si2].value &&
- " . $row_subjects['subid3'] . " != document.uniform.subject3.options[si3].value &&
- " . $row_subjects['subid3'] . " != document.uniform.subject4.options[si4].value)
- {
- document.uniform.subject3.options[sub3].disabled = true;
- document.uniform.subject3.options[sub3].style.display = 'none';
- }
- if (isvalid4 == 1 &&
- " . $row_subjects['subid4'] . " != document.uniform.subject1.options[si1].value &&
- " . $row_subjects['subid4'] . " != document.uniform.subject2.options[si2].value &&
- " . $row_subjects['subid4'] . " != document.uniform.subject3.options[si3].value &&
- " . $row_subjects['subid4'] . " != document.uniform.subject4.options[si4].value)
- {
- document.uniform.subject4.options[sub4].disabled = true;
- document.uniform.subject4.options[sub4].style.display = 'none';
- }
- }
- }
- ";
- }
- echo "
- document.uniform.subject1.options[si2].disabled = true;
- document.uniform.subject1.options[si3].disabled = true;
- document.uniform.subject1.options[si4].disabled = true;
- document.uniform.subject2.options[si1].disabled = true;
- document.uniform.subject2.options[si3].disabled = true;
- document.uniform.subject2.options[si4].disabled = true;
- document.uniform.subject3.options[si1].disabled = true;
- document.uniform.subject3.options[si2].disabled = true;
- document.uniform.subject3.options[si4].disabled = true;
- document.uniform.subject4.options[si1].disabled = true;
- document.uniform.subject4.options[si2].disabled = true;
- document.uniform.subject4.options[si3].disabled = true;
- for(var i=1; i<document.uniform.subject1.options.length; i++)
- {
- document.uniform.subject1.options[i].disabled = false;
- document.uniform.subject1.options[i].style.display = '';
- }
- }
- </script>";
- ?>
- <input type="hidden" name="combinationid" />
- <br />
- <input name="showTimetable" type="hidden" value="Show Timetable" />
- </form>
- </tr>
- </table>
- <script type="text/javascript">
- document.uniform.subject1.selectedIndex = 0;
- document.uniform.subject2.selectedIndex = 0;
- document.uniform.subject3.selectedIndex = 0;
- document.uniform.subject4.selectedIndex = 0;
- document.getElementById('div4').style.display = 'none';
- </script>
- <div id="divTimetable" style="margin-left: 10px; margin-top: 100px; width: 98%;">
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement