Advertisement
anticims19

combobox.php

Oct 5th, 2015
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6.     <script type='text/javascript' src='http://code.jquery.com/jquery-2.1.3.js'></script>
  7.     <script>
  8.         //<![CDATA[
  9.         $(window).load(function(){
  10.         $("#harga").on("change", function(){
  11.             var nilai = $("#harga :selected").attr("data-harga");
  12.             $("#hasil").val(nilai);
  13.         });
  14.         });//]]>
  15.     </script>
  16. </head>
  17. <body>
  18.    
  19.     <select id="harga">
  20.         <option value="">Pilih</option>
  21.         <?php  
  22.         include "config.php";
  23.         $pos=mysql_query("SELECT * from t_pelanggan order by no_pelanggan");
  24.         while ($r_pos=mysql_fetch_array($pos)) {       
  25.         ?>
  26.         <option value="<?php echo $r_pos['no_pelanggan'] ?>" data-harga="<?php echo $r_pos['nama'] ?>"><?php echo $r_pos['no_pelanggan'] ?></option>
  27.         <?php  
  28.         }
  29.         ?>
  30.     </select>
  31.    
  32.  
  33.     <br>
  34.     <input type="text" id="hasil">
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement