Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="select_style.css">
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript">
- function fetch_select(val)
- {
- $.ajax({
- type: 'post',
- url: 'fetch_data.php',
- data: {
- get_option:val
- },
- success: function (response) {
- document.getElementById("new_select").innerHTML=response;
- }
- });
- }
- </script>
- </head>
- <body>
- <p id="heading">Select Subject for Timesheet</p>
- <center>
- <div id="select_box">
- <select onChange="fetch_select(this.value);">
- <option>Select Stream</option>
- <?php
- $host = 'localhost';
- $user = 'xx';
- $pass = 'zzz';
- mysql_connect($host, $user, $pass);
- mysql_select_db('sample');
- $select=mysql_query("select stream from streamSub group by stream");
- while($row=mysql_fetch_array($select))
- {
- echo "<option>".$row['stream']."</option>";
- }
- ?>
- </select>
- <select id="new_select">
- </select>
- </div>
- </center>
- </body>
- </html>
- <?php
- if(isset($_POST['get_option']))
- {
- $host = 'localhost';
- $user = 'XX';
- $pass = 'ZZZ';
- mysql_connect($host, $user, $pass);
- mysql_select_db('sample');
- $stream = $_POST['get_option'];
- $find=mysql_query("select subject from streamSub where stream='$stream'");
- while($row=mysql_fetch_array($find))
- {
- echo "<option>".$row['subject']."</option>";
- }
- exit;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement