Don't like ads? PRO users don't see any ads ;-)
Guest

combo2

By: aries_ on May 23rd, 2012  |  syntax: PHP  |  size: 3.41 KB  |  hits: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  // koneksi mysql
  3.  mysql_connect('localhost', 'root', '');
  4.  mysql_select_db('aplikasi_pkl');
  5. ?>
  6.  
  7. <html>
  8. <head>
  9.  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
  10.   <script src="jquery.chained.js" type="text/javascript" charset="utf-8"></script>
  11.   <script src="jquery.chained.remote.js" type="text/javascript" charset="utf-8"></script>
  12.   <script type="text/javascript" charset="utf-8">
  13.   $(function() {
  14.    
  15.     /* For jquery.chained.js */
  16.     $("#series").chained("#mark");
  17.     $("#model").chained("#series");
  18.     $("#engine").chained("#series, #model");
  19.    
  20.     /* Show button after each pulldown has a value. */
  21.     $("#engine").bind("change", function(event) {
  22.         if ("" != $("option:selected", this).val() && "" != $("option:selected", $("#model")).val()) {
  23.             $("#button").fadeIn();
  24.         } else {
  25.             $("#button").hide();          
  26.         }
  27.     });
  28.    
  29.     $("#c").chained("#a,#b");
  30.  
  31.     /* For jquery.chained.remote.js */    
  32.     $("#series-remote").remoteChained("#mark-remote", "json.php");
  33.     $("#model-remote").remoteChained("#series-remote", "json.php");
  34.     $("#engine-remote").remoteChained("#series-remote, #model-remote", "json.php");
  35.    
  36.     /* Show button after each pulldown has a value. */
  37.     $("#engine-remote").bind("change", function(event) {
  38.         if ("" != $("option:selected", this).val() && "" != $("option:selected", $("#model-remote")).val()) {
  39.             $("#button-remote").fadeIn();
  40.         } else {
  41.             $("#button-remote").hide();          
  42.         }
  43.     });
  44.    
  45.    
  46.    
  47.     $("#c-remote").remoteChained("#a-remote,#b-remote", "json.php");
  48.    
  49.   });
  50.   </script>
  51.  
  52.  
  53.  
  54. </head>
  55. <body>
  56. <h1>Demo</h1>
  57. <form name="demo"  method="post"  action="submit.php">
  58. <table>
  59. <tr><td>Pilih Stream</td><td>:</td>
  60.       <td>
  61.           <select id="mark">
  62.           <option value="">--</option>
  63.                   <?php
  64.                  // query untuk menampilkan stream
  65.                  $query = "SELECT * FROM STREAM";
  66.                  $hasil = mysql_query($query);
  67.                  while ($data = mysql_fetch_array($hasil))
  68.                  {
  69.                     echo "<option value='".$data['STREAM']."'>".$data['STREAM']."</option>";
  70.                  }
  71.           ?>
  72.          
  73.         </select>
  74.       </td>      
  75. </tr>
  76. <tr><td>Pilih Materi</td><td>:</td>
  77.       <td>
  78.       <select id="series">
  79.          
  80.           <option value="">--</option>
  81.        
  82.          
  83.          
  84.            <?php
  85.                  // query untuk menampilkan materi
  86.                  $query = "SELECT * FROM materi_training";
  87.                  $hasil = mysql_query($query);
  88.                  while ($data2 = mysql_fetch_array($hasil))
  89.                  {
  90.                     echo "<option value='".$data2['Kode_M']." class=".$data['STREAM']."'>".$data2['NAMA_M_TRAINING']."</option>";
  91.                  }
  92.           ?>
  93.          
  94.           <option value="series-1" class="MKS">QWERTY</option>
  95.           <option value="series-3" class="BUS">ASDF</option>
  96.          
  97.          
  98.        
  99.         </select>
  100.       </td>        
  101. </tr>
  102. </table>
  103. </form>
  104. </body>
  105. </html>
  106.  
  107.  
  108.  
  109. /* struktur tablenya
  110. table stream
  111. |stream|nama|tekhnik|
  112. |MKS|MARKETING|NONTEKHNIK
  113. |BUS|BUSINESS|NONTEKHNIK|
  114.  
  115. table materi_training
  116. |KODE_M|STREAM|NAMA_M_TRAINING|
  117. 01     |MKS   |manajement|
  118. 02     |BUS   |Business PLAN|
  119. */