Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Select Worksheet</title>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
- <head>
- <body>
- <select name="kodeworksheet" id="pilih" class="easyui-validatebox" required="true">
- <?php
- include("../koneksi/conn.php");
- $sql="SELECT kodeworksheet FROM tmworksheet ORDER BY kodeworksheet";
- $query = mysql_query($sql);
- while($row=mysql_fetch_object($query))
- {
- echo "<option value=\"".$row->kodeworksheet."\">".$row->kodeworksheet."</option>\n";
- }
- ?>
- </select>
- <input type="text" id="biayaworksheet" readonly="readonly" />
- <input type="text" id="namaworksheet" readonly="readonly" />
- <input type="text" id="keterangan" readonly="readonly" />
- <script type="text/javascript">
- $('#pilih').change(function(){
- $.ajax({
- type=:'POST',
- datatype:'json',
- url:'proses.php',
- data:'id='+$(this).val(),
- success:function(html){
- $('#biayaworksheet').val(html.biaya);
- $('#namaworksheet').val(html.nama);
- $('#keterangan').val(html.keterangan);
- }
- });
- });
- </script>
- </body>
- </html>
- //========= file: proses.php =================
- <?php
- $id=isset($_POST['id'])?$_POST['id']:"";
- include("../koneksi/conn.php");
- $where=!empty($id)" WHERE kodeworksheet='".$id."' ":"";
- $sql="SELECT biayaworksheet,namaworksheet,keterangan FROM tmworksheet ".$where." ORDER BY kodeworksheet";
- $query = mysql_query($sql);
- if($query->mysql_num_rows>0){
- $row=mysql_fetch_object($query);
- $result=array("biaya"=>$row->biayaworksheet,"nama"=>$row->namaworksheet,"keterangan"=>$row->keterangan);
- }else{
- $result=array("biaya"=>"","nama"=>"","keterangan"=>"");
- }
- return json_encode($result);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement