Jump to content

help with combobox jquery (offline work online worst)


havide

Recommended Posts

lokal_lancar.jpg

online_error.jpg

I use firebug to detect how javascript work. It same code. the java script :

<script type="text/javascript">
$(function() {
     $("#cmbNegara").change(function(){
          $("img#imgLoad").show();
          var kodejeniskayu = $(this).val();
 
          $.ajax({
             type: "POST",
             dataType: "html",
             url: "getProvinsi.php",
             data: "kodejeniskayu="+kodejeniskayu,
             success: function(msg){
                 if(msg == ''){
                         $("select#cmbProvinsi").html('<option value="">--Pilih Ukuran--</option>');
                         $("select#cmbKota").html('<option value="">--Pilih Ukuran--</option>');
                 }else{
                           $("select#cmbProvinsi").html(msg);                                                       
                 }
                 $("img#imgLoad").hide();
 
                 getAjaxAlamat();                                                        
             }
          });                    
     });
 
     $("#cmbProvinsi").change(getAjaxAlamat);
     function getAjaxAlamat(){
          $("img#imgLoadMerk").show();
          var kodeukuran = $("#cmbProvinsi").val();
 
          $.ajax({
             type: "POST",
             dataType: "html",
             url: "getKota.php",
             data: "kodeukuran="+kodeukuran,
             success: function(msg){
                 if(msg == ''){
                         $("select#cmbKota").html('<option value="">--Stok Kosong--</option>');                                                                                  
                 }else{
                           $("select#cmbKota").html(msg);                              
                 }
                 $("img#imgLoadMerk").hide();                                                        
             }
          });
     };   

	
});
</script>

getprovinsi.php

<?php require_once('Connections/karyo.php'); ?>
<?php
ini_set('display_errors',0);
//ambil parameter
$kodejeniskayu = $_POST['kodejeniskayu'];

if($kodejeniskayu == ''){
     exit;
}else{
     $sql ="SELECT kodeukuran,ukuran FROM tukuran WHERE kodejeniskayu='$kodejeniskayu'";
     $getNamaProvinsi = mysql_query($sql,$karyo) or die ('Query Gagal');
     while($data = mysql_fetch_array($getNamaProvinsi)){
          echo '<option value="'.$data['kodeukuran'].'">'.$data['ukuran'].'</option>';
     }
     exit;    
}
?>

getkota.php

<?php require_once('Connections/karyo.php'); ?>
<?php
ini_set('display_errors',0);

//ambil parameter
$kodeukuran = $_POST['kodeukuran'];
 
if($kodeukuran == ''){
     exit;
}else{
     $sql ="SELECT idstok,harga FROM tstok WHERE kodeukuran = '$kodeukuran'";
     $getNamaKota = mysql_query($sql,$karyo) or die ('Query Gagal');
     while($data = mysql_fetch_array($getNamaKota)){
          echo '<option value="'.$data['idstok'].'">'.$data['harga'].'</option>';
     }
     exit;    
}
?>

the problem at online is, the combobox at getprovinsi not showing up. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.