Advertisement
Guest User

Dynamic dropdowns

a guest
Jan 26th, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. <!--sample_cess.php-->
  2.  
  3.  
  4. <html>
  5. <body>
  6. <?php session_start();
  7. $track=$_SESSION['track_sess'];
  8. $sem=$_SESSION['sem_sess'];
  9. $strand=$_SESSION['strand_sess'];
  10.  
  11. ?>
  12. <label>Track</label><br>
  13. <select name="track" onchange="window.location='session.php?track='+this.value">
  14. <option></option>
  15. <option value="Academic" <?php echo $track==='Academic' ? 'selected' : '' ?>>Academic</option>
  16. <option value="Technical-Vocational-Livelihood" <?php echo $track==='Technical-Vocational-Livelihood' ? 'selected' : '' ?>>Technical-Vocational-Livelihood</option>
  17. </select><br>
  18.  
  19. <label>Semesters</label><br>
  20. <select name="semester" onchange="window.location='session.php?sem='+this.value">
  21. <option></option>
  22. <option value="First semester" <?php echo $sem==='First semester' ? 'selected' : '' ?>>First semester</option>
  23. <option value="Second semester" <?php echo $sem==='Second semester' ? 'selected' : '' ?>>Second semester</option>
  24. </select><br>
  25.  
  26. <label>Strands</label><br>
  27. <select name="strands" onchange="window.location='session.php?strand='+this.value">
  28. <?php if($track=='Academic' && $sem=='First semester'){ ?>
  29. <option></option>
  30. <option value="Accountancy" <?php echo $strand==='Accountancy' ? 'selected' : '' ?>>Accountancy</option>
  31. <option value="Business and Management (ABM)" <?php echo $strand==='Business and Management (ABM)' ? 'selected' : '' ?>>Business and Management (ABM)</option>
  32. <option value="Science, Technology Engineering and Mathematics (STEM)" <?php echo $strand==='Science, Technology Engineering and Mathematics (STEM)' ? 'selected' : '' ?>>Science, Technology Engineering and Mathematics (STEM)</option>
  33. <option value="Humanities and Social Sciences (HUMSS)" <?php echo $strand==='Humanities and Social Sciences (HUMSS)' ? 'selected' : '' ?>>Humanities and Social Sciences (HUMSS)</option>
  34. <option value="General Academic (GAS)" <?php echo $strand==='General Academic (GAS)' ? 'selected' : '' ?>>General Academic (GAS)</option>
  35. <?php }
  36. if($track=='Technical-Vocational-Livelihood' && $sem=='First semester'){
  37. ?>
  38. <option></option>
  39. <option value="Information and Communications Technology (ICT)" <?php echo $strand==='Information and Communications Technology (ICT)' ? 'selected' : '' ?>>Information and Communications Technology (ICT)</option>
  40. <option value="Home Economics (HE)" <?php echo $strand==='Home Economics (HE)' ? 'selected' : '' ?>>Home Economics (HE)</option>
  41. <?php }
  42. if($track=='Academic' && $sem=='Second semester'){
  43. ?>
  44. <option></option>
  45. <option value="1st subject" <?php echo $strand==='1st subject' ? 'selected' : '' ?>>1st subject</option>
  46. <option value="2st subject" <?php echo $strand==='2st subject' ? 'selected' : '' ?>>2nd subject</option>
  47. <option value="3st subject" <?php echo $strand==='3st subject' ? 'selected' : '' ?>>3rd subject</option>
  48. <?php }
  49. if($track=='Technical-Vocational-Livelihood' && $sem=='Second semester'){
  50. ?>
  51. option></option>
  52. <option value="1st subject" <?php echo $strand==='1st subject' ? 'selected' : '' ?>>1st subject</option>
  53. <option value="2st subject" <?php echo $strand==='2st subject' ? 'selected' : '' ?>>2nd subject</option>
  54. <option value="3st subject" <?php echo $strand==='3st subject' ? 'selected' : '' ?>>3rd subject</option>
  55. <?php } ?>
  56. </select>
  57.  
  58. <br><br><br>
  59.  
  60. <div id="result">
  61. <?php
  62. echo $track."<br>". $_SESSION['sem_sess']."<br>". $_SESSION['strand_sess']; ?>
  63. </div>
  64.  
  65. </body>
  66. </html>
  67.  
  68. <!--session.php-->
  69. <?php
  70. session_start();
  71. $track=$_GET["track"];
  72. $sem=$_GET["sem"];
  73. $strand=$_GET["strand"];
  74.  
  75. if(isset($track)){
  76. $_SESSION['track_sess']=$track;
  77. }
  78. if(isset($sem)){
  79. $_SESSION['sem_sess']=$sem;
  80. }
  81. if(isset($strand)){
  82. $_SESSION['strand_sess']=$strand;
  83. }
  84.  
  85. header("location:sample_sess.php");
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement