1<select name="allbooks" id="allbooks">
2 <option value="none" ></option>
3 <option value="allbooks" >All Books</option>
4</select>
5<div id="show">
6 <!-- ITEMS TO BE DISPLAYED HERE -->
7</div>
8
9
10
11<script src="jquery-1.9.1.min.js"></script> <!-- CHANGE THE JQUERY FILE DEPENDING ON THE VERSION YOU HAVE DOWNLOADED -->
12<script type="text/javascript">
13 $(document).ready(function(){ /* PREPARE THE SCRIPT */
14 $("#allbooks").change(function(){ /* WHEN YOU CHANGE AND SELECT FROM THE SELECT FIELD */
15 var allbooks = $(this).val(); /* GET THE VALUE OF THE SELECTED DATA */
16 var dataString = "allbooks="+allbooks; /* STORE THAT TO A DATA STRING */
17
18 $.ajax({ /* THEN THE AJAX CALL */
19 type: "POST", /* TYPE OF METHOD TO USE TO PASS THE DATA */
20 url: "get-data.php", /* PAGE WHERE WE WILL PASS THE DATA */
21 data: dataString, /* THE DATA WE WILL BE PASSING */
22 success: function(result){ /* GET THE TO BE RETURNED DATA */
23 $("#show").html(result); /* THE RETURNED DATA WILL BE SHOWN IN THIS DIV */
24 }
25 });
26
27 });
28 });
29</script>
30
31 if(!empty($_POST["allbooks"])){
32 /* DO YOUR QUERY HERE AND GET THE OUTPUT YOU WANT */
33 echo $output; /* PRINT THE OUTPUT YOU WANT, IT WILL BE RETURNED TO THE ORIGINAL PAGE */
34}