Guest User

Untitled

a guest
Jan 30th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link rel="stylesheet" type="text/css" href="select_style.css">
  4. <script type="text/javascript" src="jquery.js"></script>
  5. <script type="text/javascript">
  6. function fetch_select(val)
  7. {
  8. $.ajax({
  9. type: 'post',
  10. url: 'fetch_data.php',
  11. data: {
  12. get_option:val
  13. },
  14. success: function (response) {
  15. document.getElementById("new_select").innerHTML=response;
  16. }
  17. });
  18. }
  19.  
  20. </script>
  21.  
  22. </head>
  23. <body>
  24. <p id="heading">Select Subject for Timesheet</p>
  25. <center>
  26. <div id="select_box">
  27. <select onChange="fetch_select(this.value);">
  28. <option>Select Stream</option>
  29. <?php
  30. $host = 'localhost';
  31. $user = 'xx';
  32. $pass = 'zzz';
  33. mysql_connect($host, $user, $pass);
  34. mysql_select_db('sample');
  35.  
  36. $select=mysql_query("select stream from streamSub group by stream");
  37. while($row=mysql_fetch_array($select))
  38. {
  39. echo "<option>".$row['stream']."</option>";
  40. }
  41.  
  42. ?>
  43. </select>
  44.  
  45. <select id="new_select">
  46. </select>
  47. </div>
  48. </center>
  49. </body>
  50. </html>
  51.  
  52. <?php
  53. if(isset($_POST['get_option']))
  54. {
  55. $host = 'localhost';
  56. $user = 'XX';
  57. $pass = 'ZZZ';
  58. mysql_connect($host, $user, $pass);
  59. mysql_select_db('sample');
  60.  
  61. $stream = $_POST['get_option'];
  62. $find=mysql_query("select subject from streamSub where stream='$stream'");
  63. while($row=mysql_fetch_array($find))
  64. {
  65. echo "<option>".$row['subject']."</option>";
  66. }
  67.  
  68. exit;
  69. }
  70. ?>
Add Comment
Please, Sign In to add comment